diff --git a/Dockerfile b/Dockerfile index fc8aa79..9b7c01b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim-bullseye +FROM python:3.12-slim-bookworm # PYTHONFAULTHANDLER: Propagate tracebacks from all threads. # PYTHONUNBUFFERED: Write terminal output straight to docker (to not confuse Docker Compose). @@ -13,14 +13,17 @@ ENV PYTHONFAULTHANDLER=1 \ PIP_DISABLE_PIP_VERSION_CHECK=on \ PIP_DEFAULT_TIMEOUT=100 ARG BUILD -ENV BUILD ${BUILD} +ENV BUILD=${BUILD} ARG REQUIREMENTS_FILE=requirements.txt WORKDIR /app RUN groupadd -g 1000 www && useradd -u 1000 -ms /bin/bash -g www www -COPY --chown=www:www . . -RUN mkdir /app/src/static && \ + +# Only copy the requirements file first to leverage Docker cache +COPY $REQUIREMENTS_FILE . + +RUN mkdir -p /app/src/static && \ chown www:www /app/src/static && \ apt-get update && \ apt-get install -y \ @@ -35,8 +38,12 @@ RUN mkdir /app/src/static && \ libffi-dev \ shared-mime-info \ gettext && \ - pip install --no-cache-dir -r $REQUIREMENTS_FILE && \ - django-admin compilemessages + pip install --no-cache-dir -r $REQUIREMENTS_FILE + +# Copy the rest of the application +COPY . . + +RUN django-admin compilemessages ENTRYPOINT ["./entrypoint.sh"]