From 9ecaea2c120fa8db4b159383918b716e2ed9f96e Mon Sep 17 00:00:00 2001 From: Philipp Fruck Date: Sun, 10 Dec 2023 22:57:37 +0000 Subject: [PATCH] chore(docker): Remove intermediate stage (#6068) removes the prebuild stage from the final image which solves the issue that build dependencies where not cleaned up properly. Saves a couple of MB in image size. --- Dockerfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba81f97a6a..9ab4b9e3df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,8 +94,9 @@ ENTRYPOINT ["/bin/sh", "./init.sh"] FROM inventree_base as prebuild +ENV PATH=/root/.local/bin:$PATH RUN ./install_build_packages.sh --no-cache --virtual .build-deps && \ - pip install -r base_requirements.txt -r requirements.txt --no-cache-dir && \ + pip install --user -r base_requirements.txt -r requirements.txt --no-cache-dir && \ apk --purge del .build-deps # Frontend builder image: @@ -111,7 +112,7 @@ RUN cd ${INVENTREE_HOME}/InvenTree && inv frontend-compile # InvenTree production image: # - Copies required files from local directory # - Starts a gunicorn webserver -FROM prebuild as production +FROM inventree_base as production ENV INVENTREE_DEBUG=False @@ -119,6 +120,10 @@ ENV INVENTREE_DEBUG=False ENV INVENTREE_COMMIT_HASH="${commit_hash}" ENV INVENTREE_COMMIT_DATE="${commit_date}" +# use dependencies and compiled wheels from the prebuild image +ENV PATH=/root/.local/bin:$PATH +COPY --from=prebuild /root/.local /root/.local + # Copy source code COPY InvenTree ./InvenTree COPY --from=frontend ${INVENTREE_HOME}/InvenTree/web/static/web ./InvenTree/web/static/web