Skip to content

Commit

Permalink
add new py-dev Docker stage and use in all later stages
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas committed Aug 2, 2024
1 parent cbeed13 commit 283a0d8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/django_twc_project/Dockerfile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 283a0d8

Please sign in to comment.