Make internal and host ports configurable via env vars

This commit is contained in:
Troll (Hermes Agent) 2026-07-31 20:43:36 +00:00
parent fa01ac0f32
commit 3ef8aaf45a
5 changed files with 12 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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')

View file

@ -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