From eb370821496e7b4f506dfc8a6a53efad25002a9b Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 9 Aug 2026 07:27:15 +1000 Subject: [PATCH] [docker] Include pip license file (#12583) * [docker] Include pip license file This file has been missing in production builds * Add CI test * Update contrib/container/Dockerfile Co-authored-by: Matthias Mair * Fix typo * path fix * More pathing fixes --------- Co-authored-by: Matthias Mair --- .github/workflows/docker.yaml | 3 +++ contrib/container/Dockerfile | 4 ++++ tasks.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index e4e640b637..323bac6200 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -84,6 +84,9 @@ jobs: docker run --rm inventree-test test -f /home/inventree/gunicorn.conf.py docker run --rm inventree-test test -f /home/inventree/src/backend/requirements.txt docker run --rm inventree-test test -f /home/inventree/src/backend/InvenTree/manage.py + # Check that license information was generated into the image + docker run --rm inventree-test test -s /home/inventree/src/backend/InvenTree/InvenTree/licenses.txt + docker run --rm inventree-test test -s /home/inventree/src/backend/InvenTree/web/static/web/.vite/dependencies.json # Check that backend translations were compiled into the image (a few representative languages) docker run --rm inventree-test test -f /home/inventree/src/backend/InvenTree/locale/de/LC_MESSAGES/django.mo docker run --rm inventree-test test -f /home/inventree/src/backend/InvenTree/locale/fr/LC_MESSAGES/django.mo diff --git a/contrib/container/Dockerfile b/contrib/container/Dockerfile index 429a0f9ddf..c30e84221e 100644 --- a/contrib/container/Dockerfile +++ b/contrib/container/Dockerfile @@ -149,6 +149,10 @@ COPY --from=builder_stage /root/.local /root/.local # Compile Django backend translations during image build RUN bash -c "cd '${INVENTREE_HOME}' && invoke int.backend-compilemessages" +# Generate license information for installed python packages +RUN pip-licenses --format=json --with-license-file --no-license-path > "${INVENTREE_BACKEND_DIR}/InvenTree/InvenTree/licenses.txt" \ + && test -s "${INVENTREE_BACKEND_DIR}/InvenTree/InvenTree/licenses.txt" + # Launch the production server CMD ["sh", "-c", "exec gunicorn -c ./gunicorn.conf.py InvenTree.wsgi -b ${INVENTREE_WEB_ADDR}:${INVENTREE_WEB_PORT} --chdir ${INVENTREE_BACKEND_DIR}/InvenTree"] diff --git a/tasks.py b/tasks.py index 6de02575f9..31c7891182 100644 --- a/tasks.py +++ b/tasks.py @@ -764,6 +764,9 @@ def install( f'pip-licenses --format=json --with-license-file --no-license-path > {lic_path}', ) + if not lic_path.exists() or lic_path.stat().st_size == 0: + raise FileNotFoundError(f"License file was not generated at '{lic_path}'") + success('Dependency installation complete')