[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 <code@mjmair.com>

* Fix typo

* path fix

* More pathing fixes

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
Oliver
2026-08-09 07:27:15 +10:00
committed by GitHub
co-authored by Matthias Mair
parent bc150e09e8
commit eb37082149
3 changed files with 10 additions and 0 deletions
+3
View File
@@ -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/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/requirements.txt
docker run --rm inventree-test test -f /home/inventree/src/backend/InvenTree/manage.py 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) # 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/de/LC_MESSAGES/django.mo
docker run --rm inventree-test test -f /home/inventree/src/backend/InvenTree/locale/fr/LC_MESSAGES/django.mo docker run --rm inventree-test test -f /home/inventree/src/backend/InvenTree/locale/fr/LC_MESSAGES/django.mo
+4
View File
@@ -149,6 +149,10 @@ COPY --from=builder_stage /root/.local /root/.local
# Compile Django backend translations during image build # Compile Django backend translations during image build
RUN bash -c "cd '${INVENTREE_HOME}' && invoke int.backend-compilemessages" 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 # 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"] CMD ["sh", "-c", "exec gunicorn -c ./gunicorn.conf.py InvenTree.wsgi -b ${INVENTREE_WEB_ADDR}:${INVENTREE_WEB_PORT} --chdir ${INVENTREE_BACKEND_DIR}/InvenTree"]
+3
View File
@@ -764,6 +764,9 @@ def install(
f'pip-licenses --format=json --with-license-file --no-license-path > {lic_path}', 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') success('Dependency installation complete')