From a871f7d731c1f8ee455e13785609a52eeecc5593 Mon Sep 17 00:00:00 2001 From: Kevin Meinhardt Date: Fri, 18 Oct 2024 12:12:34 +0200 Subject: [PATCH] Remove sources from development DOCKER_TARGET --- Dockerfile | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70a1b83258f..5e1e54b22d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -96,6 +96,10 @@ EOF ARG DOCKER_TARGET ENV DOCKER_TARGET=${DOCKER_TARGET} +# Add our custom mime types (required for for ts/json/md files) +COPY docker/etc/mime.types /etc/mime.types + + # Define production dependencies as a single layer # let's the rest of the stages inherit prod dependencies # and makes copying the /deps dir to the final layer easy. @@ -115,7 +119,10 @@ ${PIP_COMMAND} install --progress-bar=off --no-deps --exists-action=w -r require npm ci ${NPM_ARGS} --include=prod EOF -FROM base AS pip_development +# In the local development image, we stop with dependencies +# Everything else is about compiling production assets which is not needed +# in the typical development workflow. +FROM base AS development RUN \ # Files required to install pip dependencies @@ -168,7 +175,7 @@ echo "from olympia.lib.settings_base import *" > settings_local.py DJANGO_SETTINGS_MODULE="settings_local" make -f Makefile-docker update_assets EOF -FROM base AS sources +FROM base AS production ARG DOCKER_BUILD DOCKER_COMMIT DOCKER_VERSION @@ -176,21 +183,8 @@ ENV DOCKER_BUILD=${DOCKER_BUILD} ENV DOCKER_COMMIT=${DOCKER_COMMIT} ENV DOCKER_VERSION=${DOCKER_VERSION} -# Add our custom mime types (required for for ts/json/md files) -COPY docker/etc/mime.types /etc/mime.types # Copy the rest of the source files from the host COPY --chown=olympia:olympia . ${HOME} - -# Set shell back to sh until we can prove we can use bash at runtime -SHELL ["/bin/sh", "-c"] - -FROM sources AS development - -# Copy dependencies from `pip_development` -COPY --from=pip_development --chown=olympia:olympia /deps /deps - -FROM sources AS production - # Copy compiled locales from builder COPY --from=locales --chown=olympia:olympia ${HOME}/locale ${HOME}/locale # Copy assets from assets @@ -199,4 +193,5 @@ COPY --from=assets --chown=olympia:olympia ${HOME}/static-build ${HOME}/static-b # Copy dependencies from `pip_production` COPY --from=pip_production --chown=olympia:olympia /deps /deps - +# Set shell back to sh until we can prove we can use bash at runtime +SHELL ["/bin/sh", "-c"]