cdh-merger/docker-compose.yml
2025-05-21 16:55:03 +00:00

40 lines
1.3 KiB
YAML

networks:
traefik:
external: true
services:
app:
image: python:3.11-slim
container_name: flask_app
environment:
- FLASK_APP=app.py
- FLASK_ENV=production
restart: always
networks:
traefik:
volumes:
- ./app:/usr/src/app
working_dir: /usr/src/app
command: >
sh -c "
pip install --no-cache-dir -r requirements.txt &&
flask run --host=0.0.0.0 --port=${APP_PORT}"
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 mapping
- "traefik.http.services.${CONTAINER_NAME}.loadbalancer.server.port=${APP_PORT}"