diff --git a/CHANGELOG.md b/CHANGELOG.md index 2571bafa..3d30059a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added `django-perf-rec` to `dev` extras in `pyproject.toml`. - Added `pip` and `uv` to `dev` extras in `pyproject.toml`. +### Fixed + +- Added a new `py-dev` stage to the `Dockerfile` for installation of development dependencies. All intermediate stages afterwards now rely on the Python packages installed in this stage, with the exception of the final stage which only copies the production dependencies from the `py` stage. + ## [2024.41] ### Changed diff --git a/src/django_twc_project/Dockerfile.jinja b/src/django_twc_project/Dockerfile.jinja index 29892112..0585db91 100644 --- a/src/django_twc_project/Dockerfile.jinja +++ b/src/django_twc_project/Dockerfile.jinja @@ -70,8 +70,15 @@ RUN --mount=type=cache,target=/root/.cache/pip --mount=type=cache,target=/root/. && uv pip install -r requirements.txt -FROM node-base as node +FROM py as py-dev COPY --from=py --link /usr/local /usr/local +COPY --link requirements.dev.txt ./ +RUN --mount=type=cache,target=/root/.cache/pip --mount=type=cache,target=/root/.cache/uv \ + uv pip install -r requirements.dev.txt + + +FROM node-base as node +COPY --from=py-dev --link /usr/local /usr/local COPY --link package*.json /app RUN --mount=type=cache,target=/root/.npm npm install @@ -96,7 +103,6 @@ RUN case ${BUILDARCH} in \ FROM base as app -COPY --from=py --link /usr/local /usr/local COPY --link manage.py package.json /app/ COPY --link {{ module_name }} /app/{{ module_name }} COPY --link templates /app/templates @@ -105,7 +111,7 @@ COPY --link templates /app/templates FROM mcr.microsoft.com/playwright/python:v{{ playwright_version }} as dev ENV DEBIAN_FRONTEND noninteractive ENV UV_SYSTEM_PYTHON true -COPY --from=py --link /usr/local /usr/local +COPY --from=py-dev --link /usr/local /usr/local COPY --from=app --link /app /app COPY --link requirements.dev.txt ./ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -116,8 +122,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,t # (it's normally included in the Python based images) tzdata \ # cleanup - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* \ - && uv pip install -r requirements.dev.txt + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* FROM node as node-final @@ -137,7 +142,7 @@ RUN python manage.py tailwind --skip-checks build FROM app as static ENV DATABASE_URL sqlite://:memory: -COPY --from=py --link /usr/local /usr/local +COPY --from=py-dev --link /usr/local /usr/local COPY --from=node-final --link /app/static/dist /app/static/dist COPY --from=node-final --link /app/package*.json /app/ COPY --link static/public /app/static/public