agenda_culturel/docker-compose.prod.yml

130 lines
4.1 KiB
YAML
Raw Normal View History

2023-05-10 09:02:59 +02:00
version: '3.9'
services:
backend:
container_name: "${APP_NAME}-backend"
build:
context: .
dockerfile: deployment/Dockerfile
args:
- APP_NAME=${APP_NAME}
- APP_HOST=${APP_HOST}
- APP_PORT=${APP_PORT}
volumes:
- ./src:/usr/src/app/
- ./deployment/scripts:/app/deployment/scripts/
2023-05-10 12:09:50 +02:00
- static_files:/usr/src/app/static
2023-05-10 13:19:19 +02:00
- media_files:/usr/src/app/media
2023-05-10 18:22:31 +02:00
labels:
- "traefik.enable=true"
- "traefik.http.routers.${APP_NAME}-backend.rule=Host(`${APP_DOMAIN}`)"
2023-05-10 19:37:38 +02:00
- "traefik.http.routers.${APP_NAME}-backend.entrypoints=web"
2023-05-10 18:22:31 +02:00
- "traefik.http.services.${APP_NAME}-backend.loadbalancer.server.port=${APP_PORT:-8000}"
2023-05-10 09:02:59 +02:00
env_file: .env
2023-05-10 13:19:19 +02:00
expose:
- "${APP_PORT:-8000}"
2023-05-10 09:02:59 +02:00
depends_on:
2023-05-10 12:09:50 +02:00
- db
- redis
2023-05-10 09:02:59 +02:00
command: [ "/bin/sh", "/app/deployment/scripts/backend/start.sh" ]
db:
image: postgres:15.2-alpine
container_name: "${APP_NAME}-db"
hostname: "${POSTGRES_HOST:-db}"
volumes:
- postgres_data_dir:/var/lib/postgresql/data/
env_file: .env
2023-05-10 13:19:19 +02:00
expose:
- "${POSTGRES_PORT:-5432}"
2023-05-10 09:02:59 +02:00
shm_size: 1g
2023-05-10 12:09:50 +02:00
2023-05-10 09:02:59 +02:00
redis:
container_name: "${APP_NAME}-redis"
image: redis:latest
volumes:
- redis_data:/data
celery-worker: &celery-worker
container_name: "${APP_NAME}-celery-worker"
build:
context: .
dockerfile: deployment/Dockerfile
volumes:
- ./src:/usr/src/app/
- ./deployment/scripts:/app/deployment/scripts/
env_file: .env
depends_on:
- db
- redis
- backend
command: [ "/bin/sh", "/app/deployment/scripts/celery/start-worker.sh" ]
celery-beat:
<<: *celery-worker
container_name: "${APP_NAME}-celery-beat"
command: [ "/bin/sh", "/app/deployment/scripts/celery/start-beat.sh" ]
2023-05-10 12:09:50 +02:00
nginx:
image: nginx:latest
container_name: "${APP_NAME}-nginx"
volumes:
- ./deployment/scripts/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- static_files:/usr/src/app/static
2023-05-10 13:19:19 +02:00
- media_files:/usr/src/app/media
2023-05-10 12:09:50 +02:00
labels:
- "traefik.enable=true"
2023-05-10 19:24:04 +02:00
- "traefik.http.routers.${APP_NAME}-nginx.rule=Host(`${APP_DOMAIN}`)"
2023-05-10 19:37:38 +02:00
- "traefik.http.routers.${APP_NAME}-nginx.entrypoints=web"
2023-05-10 15:26:50 +02:00
- "traefik.http.services.${APP_NAME}-nginx.loadbalancer.server.port=80"
2023-05-10 16:33:37 +02:00
expose:
- "80"
2023-05-10 12:09:50 +02:00
depends_on:
2023-05-10 16:33:37 +02:00
- backend
2023-05-10 19:10:21 +02:00
- traefik
2023-05-10 12:09:50 +02:00
2023-05-10 09:02:59 +02:00
traefik:
image: traefik:v2.5
container_name: "${APP_NAME}-traefik"
command:
2023-05-10 19:37:38 +02:00
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
2023-05-10 19:06:08 +02:00
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.watch=true"
2023-05-10 19:37:38 +02:00
- "--api.dashboard=true"
2023-05-10 19:44:40 +02:00
- "--certificatesresolvers.myResolver.acme.email=${LETSENCRYPT_EMAIL}"
- "--certificatesresolvers.myResolver.acme.storage=/myResolver/acme.json"
2023-05-10 19:58:29 +02:00
- "--certificatesresolvers.myresolver.acme.dnschallenge=true"
- "--certificatesresolvers.myresolver.acme.dnschallenge.provider=ovh"
2023-05-10 19:10:21 +02:00
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
2023-05-10 19:06:08 +02:00
- "--log.level=DEBUG"
2023-05-10 19:58:29 +02:00
- "--accesslog=true"
- "--tracing=true"
- "--api=true"
2023-05-10 19:37:38 +02:00
labels:
- "traefik.http.routers.dashboard.rule=Host(`${TRAEFIK_DOMAIN}`) && (PathPrefix(`/`)"
- "traefik.http.routers.dashboard.tls=true"
2023-05-10 19:44:40 +02:00
- "traefik.http.routers.dashboard.tls.certresolver=myResolver"
2023-05-10 19:37:38 +02:00
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=user:$$2y$$05$$22TlNvU.X30m4rVd3aIA3.jF/XXkh6eayHg5UYwDNgF8MVFwJgPrS"
- "traefik.http.routers.${APP_NAME}-nginx.tls=true"
2023-05-10 19:44:40 +02:00
- "traefik.http.routers.${APP_NAME}-nginx.tls.certresolver=myResolver"
2023-05-10 09:02:59 +02:00
ports:
- "80:80"
2023-05-10 12:09:50 +02:00
- "443:443"
2023-05-10 09:02:59 +02:00
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
2023-05-10 19:44:40 +02:00
- "./myResolver:/myResolver"
2023-05-10 16:33:37 +02:00
2023-05-10 09:02:59 +02:00
volumes:
2023-05-10 12:09:50 +02:00
static_files:
2023-05-10 13:19:19 +02:00
media_files:
2023-05-10 09:02:59 +02:00
postgres_data_dir:
2023-05-10 12:09:50 +02:00
redis_data: