From be3b22ce369aa2ecb942f468d8e0a23a1b1080ea Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 09:24:22 +1000 Subject: [PATCH] Docker fix (#7228) (#7229) * Copy requirements file * Test more files when building docker image * Refactor install task * Raise exception * Run install task * Fix typos - The tests work! (cherry picked from commit 2265055785c7e841219a30d1af7bac310c36bb72) Co-authored-by: Oliver --- .github/workflows/docker.yaml | 5 +++++ contrib/container/Dockerfile | 1 + tasks.py | 11 ++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 481d9d84cf..3d1fdb40ff 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -85,12 +85,17 @@ jobs: docker run --rm inventree-test invoke --list docker run --rm inventree-test gunicorn --version docker run --rm inventree-test pg_dump --version + docker run --rm inventree-test test -f /home/inventree/init.sh + docker run --rm inventree-test test -f /home/inventree/tasks.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/InvenTree/manage.py - name: Build Docker Image # Build the development docker image (using docker-compose.yml) run: docker compose --project-directory . -f contrib/container/dev-docker-compose.yml build --no-cache - name: Update Docker Image run: | + docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke install docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke update docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke setup-dev docker compose --project-directory . -f contrib/container/dev-docker-compose.yml up -d diff --git a/contrib/container/Dockerfile b/contrib/container/Dockerfile index 2d8931c943..572a286f5d 100644 --- a/contrib/container/Dockerfile +++ b/contrib/container/Dockerfile @@ -128,6 +128,7 @@ COPY --from=prebuild /root/.local /root/.local # Copy source code COPY src/backend/InvenTree ${INVENTREE_BACKEND_DIR}/InvenTree +COPY src/backend/requirements.txt ${INVENTREE_BACKEND_DIR}/requirements.txt COPY --from=frontend ${INVENTREE_BACKEND_DIR}/InvenTree/web/static/web ${INVENTREE_BACKEND_DIR}/InvenTree/web/static/web # Launch the production server diff --git a/tasks.py b/tasks.py index 0b53ee155f..c16059c906 100644 --- a/tasks.py +++ b/tasks.py @@ -230,7 +230,12 @@ def plugins(c, uv=False): @task(help={'uv': 'Use UV package manager (experimental)'}) def install(c, uv=False): """Installs required python packages.""" - print("Installing required python packages from 'src/backend/requirements.txt'") + INSTALL_FILE = 'src/backend/requirements.txt' + + print(f"Installing required python packages from '{INSTALL_FILE}'") + + if not Path(INSTALL_FILE).is_file(): + raise FileNotFoundError(f"Requirements file '{INSTALL_FILE}' not found") # Install required Python packages with PIP if not uv: @@ -238,13 +243,13 @@ def install(c, uv=False): 'pip3 install --no-cache-dir --disable-pip-version-check -U pip setuptools' ) c.run( - 'pip3 install --no-cache-dir --disable-pip-version-check -U --require-hashes -r src/backend/requirements.txt' + f'pip3 install --no-cache-dir --disable-pip-version-check -U --require-hashes -r {INSTALL_FILE}' ) else: c.run( 'pip3 install --no-cache-dir --disable-pip-version-check -U uv setuptools' ) - c.run('uv pip install -U --require-hashes -r src/backend/requirements.txt') + c.run(f'uv pip install -U --require-hashes -r {INSTALL_FILE}') # Run plugins install plugins(c, uv=uv)