diff --git a/result/.dockerignore b/result/.dockerignore index c2658d7d1b..3bfcb92407 100644 --- a/result/.dockerignore +++ b/result/.dockerignore @@ -1 +1,3 @@ -node_modules/ +node_modules +npm-debug.log +.git diff --git a/result/Dockerfile b/result/Dockerfile index 33f0ba86fb..4bc6aa9266 100644 --- a/result/Dockerfile +++ b/result/Dockerfile @@ -1,25 +1,24 @@ -FROM node:18-slim +FROM node:20-slim -# add curl for healthcheck RUN apt-get update && \ apt-get install -y --no-install-recommends curl tini && \ rm -rf /var/lib/apt/lists/* WORKDIR /usr/local/app -# have nodemon available for local dev use (file watching) RUN npm install -g nodemon COPY package*.json ./ RUN npm ci && \ - npm cache clean --force && \ - mv /usr/local/app/node_modules /node_modules + npm cache clean --force && \ + mv /usr/local/app/node_modules /node_modules COPY . . +USER node ENV PORT=80 EXPOSE 80 ENTRYPOINT ["/usr/bin/tini", "--"] -CMD ["node", "server.js"] +CMD ["node", "server.js"] \ No newline at end of file diff --git a/vote/.dockerignore b/vote/.dockerignore new file mode 100644 index 0000000000..b0917de5e2 --- /dev/null +++ b/vote/.dockerignore @@ -0,0 +1,4 @@ +__pycache__ +*.pyc +.git +.venv diff --git a/vote/Dockerfile b/vote/Dockerfile index 2681083600..4d71ce9b42 100644 --- a/vote/Dockerfile +++ b/vote/Dockerfile @@ -1,32 +1,26 @@ -# base defines a base stage that uses the official python runtime base image FROM python:3.11-slim AS base +ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 -# Add curl for healthcheck RUN apt-get update && \ apt-get install -y --no-install-recommends curl && \ rm -rf /var/lib/apt/lists/* -# Set the application directory WORKDIR /usr/local/app -# Install our requirements.txt COPY requirements.txt ./requirements.txt RUN pip install --no-cache-dir -r requirements.txt -# dev defines a stage for development, where it'll watch for filesystem changes FROM base AS dev RUN pip install watchdog ENV FLASK_ENV=development CMD ["python", "app.py"] -# final defines the stage that will bundle the application for production FROM base AS final - -# Copy our code from the current folder to the working directory inside the container COPY . . -# Make port 80 available for links and/or publish -EXPOSE 80 +RUN useradd --no-create-home --uid 10001 appuser +USER appuser -# Define our command to be run when launching the container -CMD ["gunicorn", "app:app", "-b", "0.0.0.0:80", "--log-file", "-", "--access-logfile", "-", "--workers", "4", "--keep-alive", "0"] +ENV PORT=8080 +EXPOSE 8080 +CMD ["sh", "-c", "exec gunicorn app:app -b 0.0.0.0:${PORT} --log-file - --access-logfile - --workers 4 --keep-alive 0"] diff --git a/worker/.dockerignore b/worker/.dockerignore new file mode 100644 index 0000000000..d1f8367743 --- /dev/null +++ b/worker/.dockerignore @@ -0,0 +1,3 @@ +bin +obj +.git diff --git a/worker/Dockerfile b/worker/Dockerfile index a3f92d7e94..3b5dbc918e 100644 --- a/worker/Dockerfile +++ b/worker/Dockerfile @@ -1,12 +1,3 @@ -# because of dotnet, we always build on amd64, and target platforms in cli -# dotnet doesn't support QEMU for building or running. -# (errors common in arm/v7 32bit) https://github.com/dotnet/dotnet-docker/issues/1537 -# https://hub.docker.com/_/microsoft-dotnet -# hadolint ignore=DL3029 -# to build for a different platform than your host, use --platform= -# for example, if you were on Intel (amd64) and wanted to build for ARM, you would use: -# docker buildx build --platform "linux/arm64/v8" . - # build compiles the program for the builder's local platform FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:7.0 AS build ARG TARGETPLATFORM @@ -25,4 +16,5 @@ RUN dotnet publish -c release -o /app -a $TARGETARCH --self-contained false --no FROM mcr.microsoft.com/dotnet/runtime:7.0 WORKDIR /app COPY --from=build /app . -ENTRYPOINT ["dotnet", "Worker.dll"] +USER 10001 +ENTRYPOINT ["dotnet", "Worker.dll"] \ No newline at end of file