Update Docker configuration and scripts for multi-tenant support: change app image, adjust port settings, and clean up logs

This commit is contained in:
2026-04-21 23:20:42 +02:00
parent 9ae316cdd9
commit 2b8bf0b7d5
7 changed files with 19 additions and 20 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
NUITKA_BUILD=0 NUITKA_BUILD=0
INVENTAR_HTTP_PORT=80 INVENTAR_HTTP_PORT=80
INVENTAR_HTTPS_PORT=443 INVENTAR_HTTPS_PORT=443
INVENTAR_APP_IMAGE=ghcr.io/aiirondev/inventarsystem:latest INVENTAR_APP_IMAGE=ghcr.io/aiirondev/legendary-octo-garbanzo:latest
-1
View File
@@ -1 +0,0 @@
[2026-04-19 20:20:39,502] ERROR in app: Error during scheduler shutdown: name '__file__' is not defined
+1
View File
@@ -15,3 +15,4 @@ python-barcode
openpyxl openpyxl
cryptography cryptography
pywebpush pywebpush
py-vapid==1.9.0
+3 -6
View File
@@ -69,9 +69,9 @@ services:
image: mongo:7.0 image: mongo:7.0
container_name: inventarsystem-mongodb container_name: inventarsystem-mongodb
restart: unless-stopped restart: unless-stopped
command: mongod --wiredTigerCacheSizeGB 2 --journal --dbPath /data/db command: mongod --wiredTigerCacheSizeGB 2
ports: expose:
- "27017:27017" - "27017"
volumes: volumes:
- mongodb_data:/data/db - mongodb_data:/data/db
- ./docker/mongo:/docker-entrypoint-initdb.d:ro - ./docker/mongo:/docker-entrypoint-initdb.d:ro
@@ -191,9 +191,6 @@ volumes:
networks: networks:
inventar-net: inventar-net:
driver: bridge driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
# Scale guidance: # Scale guidance:
# 1 tenant (20 users): 1 app instance + redis + mongodb = ~500MB # 1 tenant (20 users): 1 app instance + redis + mongodb = ~500MB
+5 -4
View File
@@ -37,7 +37,8 @@ upstream inventar_backend {
# Main HTTPS server block # Main HTTPS server block
server { server {
listen 443 ssl http2; listen 443 ssl;
http2 on;
server_name ~^(?<tenant>[a-z0-9-]+)?\.?example\.com$; server_name ~^(?<tenant>[a-z0-9-]+)?\.?example\.com$;
# SSL Configuration (wildcard certificate) # SSL Configuration (wildcard certificate)
@@ -75,9 +76,9 @@ server {
application/x-javascript application/xml+rss application/json; application/x-javascript application/xml+rss application/json;
gzip_comp_level 5; gzip_comp_level 5;
# Access/Error logs with tenant in filename # Access/Error logs
access_log /var/log/nginx/inventar_access_${tenant}.log combined buffer=32k; access_log /var/log/nginx/inventar_access.log combined buffer=32k;
error_log /var/log/nginx/inventar_error_${tenant}.log warn; error_log /var/log/nginx/inventar_error.log warn;
# Root location - proxy to app with tenant context # Root location - proxy to app with tenant context
location / { location / {
+1
View File
@@ -14,3 +14,4 @@ python-barcode
openpyxl openpyxl
cryptography cryptography
pywebpush pywebpush
py-vapid==1.9.0
+8 -8
View File
@@ -14,8 +14,8 @@ if [ "$(id -u)" -ne 0 ] && command -v sudo >/dev/null 2>&1; then
fi fi
NUITKA_BUILD_VALUE="0" NUITKA_BUILD_VALUE="0"
HTTP_PORT_VALUE="80" HTTP_PORT_VALUE="8001"
HTTPS_PORT_VALUE="443" HTTPS_PORT_VALUE="8443"
CRON_SETUP_VALUE="${INVENTAR_SETUP_CRON:-1}" CRON_SETUP_VALUE="${INVENTAR_SETUP_CRON:-1}"
APP_IMAGE_VALUE="${INVENTAR_APP_IMAGE:-$APP_IMAGE_REPO:latest}" APP_IMAGE_VALUE="${INVENTAR_APP_IMAGE:-$APP_IMAGE_REPO:latest}"
COMPOSE_FILE="docker-compose.yml" 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)" requested_http="$(awk -F= '/^INVENTAR_HTTP_PORT=/{print $2}' "$ENV_FILE" | tr -d ' ' || true)"
fi fi
if [ -z "$requested_http" ]; then if [ -z "$requested_http" ]; then
requested_http="80" requested_http="8001"
fi fi
if stack_owns_host_port "$requested_http" "80"; then if stack_owns_host_port "$requested_http" "80"; then
HTTP_PORT_VALUE="$requested_http" HTTP_PORT_VALUE="$requested_http"
elif port_in_use "$requested_http"; then elif port_in_use "$requested_http"; then
stop_host_nginx_services || true
if ! port_in_use "$requested_http"; then if ! port_in_use "$requested_http"; then
HTTP_PORT_VALUE="$requested_http" HTTP_PORT_VALUE="$requested_http"
echo "Freed HTTP port $requested_http by stopping host nginx service" echo "Freed HTTP port $requested_http by stopping host nginx service"
else else
HTTP_PORT_VALUE="$(find_free_port 8080)" 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 fi
else else
HTTP_PORT_VALUE="$requested_http" HTTP_PORT_VALUE="$requested_http"
@@ -524,13 +524,13 @@ configure_host_ports() {
fi fi
if [ -z "$requested_https" ]; then if [ -z "$requested_https" ]; then
requested_https="443" requested_https="8443"
fi fi
if stack_owns_host_port "$requested_https" "443"; then if stack_owns_host_port "$requested_https" "443"; then
HTTPS_PORT_VALUE="$requested_https" HTTPS_PORT_VALUE="$requested_https"
elif port_in_use "$requested_https"; then elif port_in_use "$requested_https"; then
stop_host_nginx_services || true
if ! port_in_use "$requested_https"; then if ! port_in_use "$requested_https"; then
HTTPS_PORT_VALUE="$requested_https" HTTPS_PORT_VALUE="$requested_https"
@@ -539,7 +539,7 @@ configure_host_ports() {
fi fi
HTTPS_PORT_VALUE="$(find_free_port 8443)" 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 else
HTTPS_PORT_VALUE="$requested_https" HTTPS_PORT_VALUE="$requested_https"
fi fi