From 3821a48f6ffd8bb5a01315f007a9c85b35378642 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Wed, 12 Feb 2025 10:14:35 +0000 Subject: [PATCH] Update `Dockerfile` --- Dockerfile | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 725f6e6..635fb26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,24 @@ -# Build an intermediate image for the Python requirements -FROM python:3.9-slim-buster as intermediate +FROM python:3.11-alpine AS base -# Install Git and Python requirements -RUN apt update && apt install -y build-essential +FROM base AS build COPY requirements.txt . RUN python -m pip install --user -r requirements.txt -# Start from a fresh image -FROM python:3.9-slim-buster - -# Keeps Python from generating .pyc files in the container -ENV PYTHONDONTWRITEBYTECODE=1 - -# Turns off buffering for easier container logging -ENV PYTHONUNBUFFERED=1 - -RUN useradd -u 4000 -d /app appuser +FROM base AS app +ENV PATH=$PATH:/app/.local/bin +RUN adduser -u 4000 -h /app -D appuser WORKDIR /app - -# Copy over the Python requirements from the intermediate container -COPY --from=intermediate /root/.local /app/.local - -RUN chown -R appuser: /app - USER appuser -# Set the main execution command -ENTRYPOINT [".local/bin/waitress-serve", "main:app"] -# HEALTHCHECK --interval=5s --timeout=30s --start-period=5s --retries=3 CMD [ "/app/healthcheck.sh" ] -EXPOSE 8080/tcp - -# Copy in the code +COPY --chown=appuser --from=build /root/.local /app/.local COPY slinky slinky/ COPY templates templates/ COPY config.yaml . COPY main.py . + +FROM app +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 +ENV PYTHONPATH=/app +ENTRYPOINT ["waitress-serve", "main:app"] +EXPOSE 8080/tcp