2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-13 10:33:07 +00:00

[Docker] Alpine image fix (#9118)

* Revert to alpine3:20 / postgres:16

* Remove old hack

- No longer needed as we are using python 3.11

* Update package requirements for devcontainer

Also fixes some docker warnings from the alpine Dockerfile

* Specify SITE_URL

* Reduce log output during docker image testing
This commit is contained in:
Oliver 2025-02-21 18:02:39 +11:00 committed by GitHub
parent 96bca652c4
commit 15ad62494f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 17 additions and 24 deletions

View File

@ -27,7 +27,7 @@ RUN apt update && apt install -y \
postgresql-client \ postgresql-client \
libldap2-dev libsasl2-dev \ libldap2-dev libsasl2-dev \
libpango1.0-0 libcairo2 \ libpango1.0-0 libcairo2 \
weasyprint poppler-utils weasyprint
# Install packages required for frontend development # Install packages required for frontend development
RUN apt install -y \ RUN apt install -y \

View File

@ -9,8 +9,7 @@
# - Runs InvenTree web server under django development server # - Runs InvenTree web server under django development server
# - Monitors source files for any changes, and live-reloads server # - Monitors source files for any changes, and live-reloads server
FROM python:3.11-alpine3.21 AS inventree_base FROM python:3.11-alpine3.20 AS inventree_base
ARG base_image
# Build arguments for this image # Build arguments for this image
ARG commit_tag="" ARG commit_tag=""
@ -19,8 +18,8 @@ ARG commit_date=""
ARG data_dir="data" ARG data_dir="data"
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK 1 ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV INVOKE_RUN_SHELL="/bin/ash" ENV INVOKE_RUN_SHELL="/bin/ash"
ENV INVENTREE_DOCKER="true" ENV INVENTREE_DOCKER="true"
@ -48,8 +47,7 @@ ENV INVENTREE_BACKGROUND_WORKERS="4"
ENV INVENTREE_WEB_ADDR=0.0.0.0 ENV INVENTREE_WEB_ADDR=0.0.0.0
ENV INVENTREE_WEB_PORT=8000 ENV INVENTREE_WEB_PORT=8000
LABEL org.opencontainers.image.created=${DATE} \ LABEL org.opencontainers.image.vendor="inventree" \
org.opencontainers.image.vendor="inventree" \
org.opencontainers.image.title="InvenTree backend server" \ org.opencontainers.image.title="InvenTree backend server" \
org.opencontainers.image.description="InvenTree is the open-source inventory management system" \ org.opencontainers.image.description="InvenTree is the open-source inventory management system" \
org.opencontainers.image.url="https://inventree.org" \ org.opencontainers.image.url="https://inventree.org" \
@ -57,7 +55,6 @@ LABEL org.opencontainers.image.created=${DATE} \
org.opencontainers.image.source="https://github.com/inventree/InvenTree" \ org.opencontainers.image.source="https://github.com/inventree/InvenTree" \
org.opencontainers.image.revision=${commit_hash} \ org.opencontainers.image.revision=${commit_hash} \
org.opencontainers.image.licenses="MIT" \ org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.base.name="docker.io/library/${base_image}" \
org.opencontainers.image.version=${commit_tag} org.opencontainers.image.version=${commit_tag}
@ -68,8 +65,8 @@ RUN apk add --no-cache \
libjpeg libwebp zlib \ libjpeg libwebp zlib \
# Weasyprint requirements : https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#alpine-3-12 # Weasyprint requirements : https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#alpine-3-12
py3-pip py3-pillow py3-cffi py3-brotli pango poppler-utils openldap \ py3-pip py3-pillow py3-cffi py3-brotli pango poppler-utils openldap \
# Postgres client (note: backwards compatible with postgres server <= 17) # Postgres client (note: backwards compatible with postgres server <= 16)
postgresql17-client \ postgresql16-client \
# MySQL / MariaDB client # MySQL / MariaDB client
mariadb-client mariadb-connector-c \ mariadb-client mariadb-connector-c \
&& \ && \

View File

@ -1,9 +1,11 @@
# InvenTree environment variables for a development setup # InvenTree environment variables for a development setup
# These variables will be used by the docker-compose.yml file # These variables will be used by the docker-compose.yml file
INVENTREE_SITE_URL=http://localhost:8000
# Set DEBUG to True for a development setup # Set DEBUG to True for a development setup
INVENTREE_DEBUG=True INVENTREE_DEBUG=True
INVENTREE_LOG_LEVEL=INFO INVENTREE_LOG_LEVEL=WARNING
INVENTREE_DB_LOGGING=False INVENTREE_DB_LOGGING=False
# Database configuration options # Database configuration options

View File

@ -1,12 +1,11 @@
#!/bin/ash #!/bin/ash
# Install system packages required for building InvenTree python libraries # Install system packages required for building InvenTree python libraries
# Note that for postgreslql, we use the version 13, which matches the version used in the InvenTree docker image
apk add gcc g++ musl-dev openssl-dev libffi-dev cargo python3-dev openldap-dev \ apk add gcc g++ musl-dev openssl-dev libffi-dev cargo python3-dev openldap-dev \
libstdc++ build-base linux-headers py3-grpcio \ libstdc++ build-base linux-headers py3-grpcio \
jpeg-dev openjpeg-dev libwebp-dev zlib-dev \ jpeg-dev openjpeg-dev libwebp-dev zlib-dev \
sqlite sqlite-dev \ sqlite sqlite-dev \
mariadb-connector-c-dev mariadb-client mariadb-dev \ mariadb-connector-c-dev mariadb-client mariadb-dev \
postgresql17-dev postgresql-libs \ postgresql16-dev postgresql-libs \
$@ $@

View File

@ -123,7 +123,11 @@ Connecting to a different database container is entirely possible, but requires
The `inventree-server` and `inventree-worker` containers support connection to a postgres database up to (and including) version {{ config.extra.docker_postgres_version }}. The `inventree-server` and `inventree-worker` containers support connection to a postgres database up to (and including) version {{ config.extra.docker_postgres_version }}.
!!! warning "Newer Postgres Versions" !!! warning "Newer Postgres Versions"
The InvenTree docker image supports connection to a postgres database up to version {{ config.extra.docker_postgres_version }}. Connecting to a database using a newer version of postgres is not possible. The InvenTree docker image supports connection to a postgres database up to version {{ config.extra.docker_postgres_version }}. Connecting to a database using a newer version of postgres is not guaranteed.
#### Bypassing Backup Procedure
If you are connecting the docker container to a postgresql database newer than version `{{ config.extra.docker_postgres_version }}`, the [backup and restore commands](../start/backup.md) will fail due to a version mismatch. To bypass this issue when performing the `invoke update` command, add the `--skip-backup` flag.
## Common Issues ## Common Issues

View File

@ -285,7 +285,7 @@ extra:
min_python_version: 3.9 min_python_version: 3.9
min_invoke_version: 2.0.0 min_invoke_version: 2.0.0
django_version: 4.2 django_version: 4.2
docker_postgres_version: 17 docker_postgres_version: 16
version: version:
default: stable default: stable

View File

@ -47,15 +47,6 @@ if TESTING:
TEST_RUNNER = 'django_slowtests.testrunner.DiscoverSlowestTestsRunner' TEST_RUNNER = 'django_slowtests.testrunner.DiscoverSlowestTestsRunner'
NUM_SLOW_TESTS = 25 NUM_SLOW_TESTS = 25
# Note: The following fix is "required" for docker build workflow
# Note: 2022-12-12 still unsure why...
if os.getenv('INVENTREE_DOCKER'):
# Ensure that sys.path includes global python libs
site_packages = '/usr/local/lib/python3.9/site-packages'
if site_packages not in sys.path:
print('Adding missing site-packages path:', site_packages)
sys.path.append(site_packages)
# Are environment variables manipulated by tests? Needs to be set by testing code # Are environment variables manipulated by tests? Needs to be set by testing code
TESTING_ENV = False TESTING_ENV = False