You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The title to my question is a bit of a mouthful, so perhaps an example will make this most clear. I've got a Dockerfile that is used to build several variants of a Python application
The below Dockerfile defines two images production and development which share a common runtime base stage and copy their dependencies from related build stages. As I understand it, in this situation, when using registry cache, it is recommended to use the max mode, so as to cache intermediate stages.
The question yes: is there any harm in using mode=max for both production and development? Would it be more correct to use mode=max for development which adds to production and mode=min for production?
### runtime-base: contains minimal common dependencies ###FROM python:3.11.9-slim-bullseye AS runtime-base
ENV VIRTUAL_ENV=/venv
RUN apt-get install -yq build-essential
### build stages ###FROM runtime-base AS production-build
RUN pip install pdm
COPY pyproject.toml pdm.lock .
WORKDIR /build
RUN pdm sync
FROM production-build AS development-build
RUN pdm sync --dev
### runtime stages ###FROM runtime-base AS production
COPY --from=production-build ${VIRTUAL_ENV} ${VIRTUAL_ENV}
FROM runtime-base AS development
COPY --from=development-build ${VIRTUAL_ENV} ${VIRTUAL_ENV}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The title to my question is a bit of a mouthful, so perhaps an example will make this most clear. I've got a Dockerfile that is used to build several variants of a Python application
The below Dockerfile defines two images
production
anddevelopment
which share a common runtime base stage and copy their dependencies from related build stages. As I understand it, in this situation, when using registry cache, it is recommended to use themax
mode, so as to cache intermediate stages.The question yes: is there any harm in using
mode=max
for bothproduction
anddevelopment
? Would it be more correct to usemode=max
fordevelopment
which adds to production andmode=min
forproduction
?An example
bake
file to go with the above.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions