bethaus-app/docker-compose.yml
2025-03-31 18:14:45 +00:00

73 lines
2.2 KiB
YAML
Executable File

services:
flask-app:
image: python:3.11-slim
container_name: ${CONTAINER_NAME}
restart: always
working_dir: /app
volumes:
- ./:/app
- ./filecache:/app/filecache
- ./templates:/app/templates
- ./GeoLite2-City.mmdb:/app/GeoLite2-City.mmdb:ro
- type: bind
source: /mnt
target: /mnt
bind:
propagation: rshared
environment:
- FLASK_APP=app.py
- FLASK_ENV=production
- TITLE_SHORT=${TITLE_SHORT}
- TITLE_LONG=${TITLE_LONG}
- DB_HOST=${CONTAINER_NAME}.sql
- DB_PORT=5432
- DB_USER=${POSTGRES_USER}
- DB_PASSWORD=${POSTGRES_PASSWORD}
- DB_NAME=${POSTGRES_DB}
depends_on:
- postgres
networks:
- traefik
- internal
labels:
- "traefik.enable=true"
# HTTP router (port 80), redirecting to HTTPS
- "traefik.http.routers.${CONTAINER_NAME}.rule=${HOST_RULE}"
- "traefik.http.routers.${CONTAINER_NAME}.entrypoints=web"
- "traefik.http.routers.${CONTAINER_NAME}.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
# HTTPS router (TLS via Let's Encrypt)
- "traefik.http.routers.${CONTAINER_NAME}-secure.rule=${HOST_RULE}"
- "traefik.http.routers.${CONTAINER_NAME}-secure.entrypoints=websecure"
- "traefik.http.routers.${CONTAINER_NAME}-secure.tls=true"
- "traefik.http.routers.${CONTAINER_NAME}-secure.tls.certresolver=myresolver"
# Internal port
- "traefik.http.services.${CONTAINER_NAME}.loadbalancer.server.port=5000"
# Production-ready Gunicorn command with eventlet
command: >
sh -c "pip install -r requirements.txt &&
gunicorn --worker-class eventlet -w 1 -b 0.0.0.0:5000 app:app"
postgres:
image: postgres:15
container_name: "${CONTAINER_NAME}.sql"
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- ./postgres_data:/var/lib/postgresql/data
networks:
- internal
networks:
traefik:
external: true
internal:
internal: true