Skip to content

Commit

Permalink
Docker fix (#7228) (#7229)
Browse files Browse the repository at this point in the history
* 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 2265055)

Co-authored-by: Oliver <[email protected]>
  • Loading branch information
github-actions[bot] and SchrodingersGat authored May 14, 2024
1 parent 258b8e4 commit be3b22c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions contrib/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,26 @@ 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:
c.run(
'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)
Expand Down

0 comments on commit be3b22c

Please sign in to comment.