From 2b8bf0b7d5f96af95f1f37b0fc7f9a45b3cd2744 Mon Sep 17 00:00:00 2001 From: AIIrondev Date: Tue, 21 Apr 2026 23:20:42 +0200 Subject: [PATCH] Update Docker configuration and scripts for multi-tenant support: change app image, adjust port settings, and clean up logs --- .docker-build.env | 2 +- Web/flask.log | 1 - Web/requirements.txt | 1 + docker-compose-multitenant.yml | 9 +++------ docker/nginx/multitenant.conf | 9 +++++---- requirements.txt | 1 + start.sh | 16 ++++++++-------- 7 files changed, 19 insertions(+), 20 deletions(-) delete mode 100644 Web/flask.log diff --git a/.docker-build.env b/.docker-build.env index 5b4d4e9..16020a7 100644 --- a/.docker-build.env +++ b/.docker-build.env @@ -1,4 +1,4 @@ NUITKA_BUILD=0 INVENTAR_HTTP_PORT=80 INVENTAR_HTTPS_PORT=443 -INVENTAR_APP_IMAGE=ghcr.io/aiirondev/inventarsystem:latest +INVENTAR_APP_IMAGE=ghcr.io/aiirondev/legendary-octo-garbanzo:latest diff --git a/Web/flask.log b/Web/flask.log deleted file mode 100644 index 9982f33..0000000 --- a/Web/flask.log +++ /dev/null @@ -1 +0,0 @@ -[2026-04-19 20:20:39,502] ERROR in app: Error during scheduler shutdown: name '__file__' is not defined diff --git a/Web/requirements.txt b/Web/requirements.txt index 69bdf6e..e21f9cb 100755 --- a/Web/requirements.txt +++ b/Web/requirements.txt @@ -15,3 +15,4 @@ python-barcode openpyxl cryptography pywebpush +py-vapid==1.9.0 diff --git a/docker-compose-multitenant.yml b/docker-compose-multitenant.yml index f90da79..6f7a5fc 100644 --- a/docker-compose-multitenant.yml +++ b/docker-compose-multitenant.yml @@ -69,9 +69,9 @@ services: image: mongo:7.0 container_name: inventarsystem-mongodb restart: unless-stopped - command: mongod --wiredTigerCacheSizeGB 2 --journal --dbPath /data/db - ports: - - "27017:27017" + command: mongod --wiredTigerCacheSizeGB 2 + expose: + - "27017" volumes: - mongodb_data:/data/db - ./docker/mongo:/docker-entrypoint-initdb.d:ro @@ -191,9 +191,6 @@ volumes: networks: inventar-net: driver: bridge - ipam: - config: - - subnet: 172.20.0.0/16 # Scale guidance: # 1 tenant (20 users): 1 app instance + redis + mongodb = ~500MB diff --git a/docker/nginx/multitenant.conf b/docker/nginx/multitenant.conf index fd9d381..477ca56 100644 --- a/docker/nginx/multitenant.conf +++ b/docker/nginx/multitenant.conf @@ -37,7 +37,8 @@ upstream inventar_backend { # Main HTTPS server block server { - listen 443 ssl http2; + listen 443 ssl; + http2 on; server_name ~^(?[a-z0-9-]+)?\.?example\.com$; # SSL Configuration (wildcard certificate) @@ -75,9 +76,9 @@ server { application/x-javascript application/xml+rss application/json; gzip_comp_level 5; - # Access/Error logs with tenant in filename - access_log /var/log/nginx/inventar_access_${tenant}.log combined buffer=32k; - error_log /var/log/nginx/inventar_error_${tenant}.log warn; + # Access/Error logs + access_log /var/log/nginx/inventar_access.log combined buffer=32k; + error_log /var/log/nginx/inventar_error.log warn; # Root location - proxy to app with tenant context location / { diff --git a/requirements.txt b/requirements.txt index 431cf43..4c64cc3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,3 +14,4 @@ python-barcode openpyxl cryptography pywebpush +py-vapid==1.9.0 diff --git a/start.sh b/start.sh index 2dd1058..0f9003a 100755 --- a/start.sh +++ b/start.sh @@ -14,8 +14,8 @@ if [ "$(id -u)" -ne 0 ] && command -v sudo >/dev/null 2>&1; then fi NUITKA_BUILD_VALUE="0" -HTTP_PORT_VALUE="80" -HTTPS_PORT_VALUE="443" +HTTP_PORT_VALUE="8001" +HTTPS_PORT_VALUE="8443" CRON_SETUP_VALUE="${INVENTAR_SETUP_CRON:-1}" APP_IMAGE_VALUE="${INVENTAR_APP_IMAGE:-$APP_IMAGE_REPO:latest}" COMPOSE_FILE="docker-compose.yml" @@ -499,20 +499,20 @@ configure_host_ports() { requested_http="$(awk -F= '/^INVENTAR_HTTP_PORT=/{print $2}' "$ENV_FILE" | tr -d ' ' || true)" fi if [ -z "$requested_http" ]; then - requested_http="80" + requested_http="8001" fi if stack_owns_host_port "$requested_http" "80"; then HTTP_PORT_VALUE="$requested_http" elif port_in_use "$requested_http"; then - stop_host_nginx_services || true + if ! port_in_use "$requested_http"; then HTTP_PORT_VALUE="$requested_http" echo "Freed HTTP port $requested_http by stopping host nginx service" else HTTP_PORT_VALUE="$(find_free_port 8080)" - echo "HTTP port 80 is in use. Using fallback HTTP port: $HTTP_PORT_VALUE" + echo "HTTP port is in use. Using fallback HTTP port: $HTTP_PORT_VALUE" fi else HTTP_PORT_VALUE="$requested_http" @@ -524,13 +524,13 @@ configure_host_ports() { fi if [ -z "$requested_https" ]; then - requested_https="443" + requested_https="8443" fi if stack_owns_host_port "$requested_https" "443"; then HTTPS_PORT_VALUE="$requested_https" elif port_in_use "$requested_https"; then - stop_host_nginx_services || true + if ! port_in_use "$requested_https"; then HTTPS_PORT_VALUE="$requested_https" @@ -539,7 +539,7 @@ configure_host_ports() { fi HTTPS_PORT_VALUE="$(find_free_port 8443)" - echo "HTTPS port 443 is in use. Using fallback HTTPS port: $HTTPS_PORT_VALUE" + echo "HTTPS port is in use. Using fallback HTTPS port: $HTTPS_PORT_VALUE" else HTTPS_PORT_VALUE="$requested_https" fi