117 lines
3.4 KiB
YAML
117 lines
3.4 KiB
YAML
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/
|
|
- static_files:/usr/src/app/static
|
|
- media_files:/usr/src/app/media
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.routers.${APP_NAME}-backend.rule=Host(`${APP_DOMAIN}`)"
|
|
- "traefik.http.routers.${APP_NAME}-backend.entrypoints=web-secure"
|
|
- "traefik.http.services.${APP_NAME}-backend.loadbalancer.server.port=${APP_PORT}"
|
|
- "traefik.http.routers.${APP_NAME}-backend.tls.certresolver=letsencrypt"
|
|
env_file: .env
|
|
expose:
|
|
- "${APP_PORT:-8000}"
|
|
depends_on:
|
|
- db
|
|
- redis
|
|
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
|
|
expose:
|
|
- "${POSTGRES_PORT:-5432}"
|
|
shm_size: 1g
|
|
|
|
|
|
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" ]
|
|
|
|
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
|
|
- media_files:/usr/src/app/media
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.routers.${APP_NAME}-nginx.rule=Host(`${APP_HOST}`) && (PathPrefix(`/static`) || PathPrefix(`/media`))"
|
|
- "traefik.http.routers.${APP_NAME}-nginx.entrypoints=web"
|
|
- "traefik.http.services.${APP_NAME}-nginx.loadbalancer.server.port=80"
|
|
depends_on:
|
|
- backend
|
|
|
|
traefik:
|
|
image: traefik:v2.5
|
|
container_name: "${APP_NAME}-traefik"
|
|
command:
|
|
- "--providers.docker=true"
|
|
- "--providers.docker.exposedbydefault=false"
|
|
- "--entrypoints.web.address=:80"
|
|
- "--entrypoints.web-secure.address=:443"
|
|
- "--log.level=DEBUG"
|
|
- "--log.format=json"
|
|
- "--log.filePath=/logs/traefik.log"
|
|
- "--accesslog=true"
|
|
- "--accesslog.filePath=/logs/access.log"
|
|
- "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
|
|
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
|
|
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
|
|
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
|
- "./letsencrypt:/letsencrypt"
|
|
networks:
|
|
- default
|
|
|
|
volumes:
|
|
static_files:
|
|
media_files:
|
|
postgres_data_dir:
|
|
redis_data:
|
|
letsencrypt:
|