From 3ef8aaf45a4041dee90439ede2c3813637b2add5 Mon Sep 17 00:00:00 2001 From: "Troll (Hermes Agent)" Date: Fri, 31 Jul 2026 20:43:36 +0000 Subject: [PATCH] Make internal and host ports configurable via env vars --- .env.example | 2 ++ Dockerfile | 4 +++- README.md | 4 +++- config.py | 3 +++ docker-compose.yml | 5 +---- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 6502dae..e3d6be4 100644 --- a/.env.example +++ b/.env.example @@ -10,5 +10,7 @@ PUBLIC_BASE_URL=http://127.0.0.1:5000 BOOTH_NAME=Trollgorithm Theme Songs DATABASE=/app/data/booth.db UPLOAD_FOLDER=/app/uploads +INTERNAL_PORT=8000 +HOST_PORT=127.0.0.1:8000 PRICE_PER_VERSION=10.00 CURRENCY=CAD diff --git a/Dockerfile b/Dockerfile index c61bfe4..5c52bed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,8 @@ ENV PYTHONUNBUFFERED=1 RUN useradd -m -u 1000 boothuser && mkdir -p /app/data /app/uploads && chown -R boothuser:boothuser /app USER boothuser +# Default internal port; override with INTERNAL_PORT env var EXPOSE 8000 -CMD ["gunicorn", "-b", "0.0.0.0:8000", "--access-logfile", "-", "app:app"] +# Use shell form so environment variables are expanded at runtime +CMD gunicorn -b 0.0.0.0:${INTERNAL_PORT:-8000} --access-logfile - app:app diff --git a/README.md b/README.md index 38a83fa..ba69369 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,15 @@ The repo includes a `docker-compose.yml` that builds directly from GitLab, so Po - `ADMIN_PASSWORD` - `SMTP_PASS` - `PUBLIC_BASE_URL` (your HTTPS domain) + - `INTERNAL_PORT` (default `8000`) — port the container listens on + - `HOST_PORT` (default `127.0.0.1:8000`) — host-side mapping to avoid conflicts with other containers - `BOOTH_NAME` (optional) 5. Deploy the stack. 6. Open a console into the `booth` container and run once: ```bash python init_db.py ``` -7. Point your reverse proxy (Nginx Proxy Manager, Traefik, Caddy, etc.) at `http://host-ip:8000` on the chosen domain. +7. Point your reverse proxy at the `HOST_PORT` you chose (e.g. `http://host-ip:8000`). 8. Print the booth QR code pointing to `https://your-domain/request`. ### Portainer Notes diff --git a/config.py b/config.py index b9cd4cc..97ca1bf 100644 --- a/config.py +++ b/config.py @@ -21,6 +21,9 @@ class Config: PUBLIC_BASE_URL = os.environ.get('PUBLIC_BASE_URL', 'http://127.0.0.1:5000') BOOTH_NAME = os.environ.get('BOOTH_NAME', 'Trollgorithm Theme Songs') + # Port the container listens on internally (gunicorn) + INTERNAL_PORT = int(os.environ.get('INTERNAL_PORT', '8000')) + # Price settings (informational, for receipt page) PRICE_PER_VERSION = float(os.environ.get('PRICE_PER_VERSION', '10.00')) CURRENCY = os.environ.get('CURRENCY', 'CAD') diff --git a/docker-compose.yml b/docker-compose.yml index 1fa2acf..8a7cb60 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,12 @@ services: booth: - # Option A: use a pre-built image (push this from CI or build locally and tag) - # image: registry.gitlab.hallsworth.ca/yrtria/theme-song-booth:latest - # Option B: build directly from the GitLab repo in Portainer build: context: https://gitlab.hallsworth.ca/yrtria/theme-song-booth.git#main container_name: theme-song-booth restart: unless-stopped env_file: .env ports: - - "127.0.0.1:8000:8000" + - "${HOST_PORT:-127.0.0.1:8000}:${INTERNAL_PORT:-8000}" volumes: - booth-data:/app/data - booth-uploads:/app/uploads