forked from mtusi2026/mtusi2026lab6
162 lines
3.5 KiB
YAML
162 lines
3.5 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:16.6-bookworm
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
|
POSTGRES_USER: ${POSTGRES_USER}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 15
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
redis:
|
|
image: redis:7.4.2-alpine
|
|
command: ["redis-server", "--appendonly", "yes", "--save", "60", "1000"]
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
rabbitmq:
|
|
image: rabbitmq:4.0.5-management-alpine
|
|
environment:
|
|
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
|
|
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
|
|
volumes:
|
|
- rabbitmq_data:/var/lib/rabbitmq
|
|
healthcheck:
|
|
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
seaweedfs:
|
|
image: chrislusf/seaweedfs:4.46
|
|
command: ["mini", "-dir=/data"]
|
|
environment:
|
|
AWS_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID}
|
|
AWS_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY}
|
|
S3_BUCKET: ${S3_BUCKET}
|
|
volumes:
|
|
- seaweedfs_data:/data
|
|
ports:
|
|
- "127.0.0.1:8333:8333"
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
migrate:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
env_file: .env
|
|
command: ["alembic", "upgrade", "head"]
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
disable: true
|
|
restart: "no"
|
|
networks:
|
|
- backend
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
env_file: .env
|
|
expose:
|
|
- "8080"
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
seaweedfs:
|
|
condition: service_started
|
|
redis:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
outbox-publisher:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
env_file: .env
|
|
command: ["python", "-m", "app.services.outbox_publisher"]
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
disable: true
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
worker:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
env_file: .env
|
|
cpus: 1.0
|
|
mem_limit: 1g
|
|
command: ["python", "-m", "app.worker"]
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
seaweedfs:
|
|
condition: service_started
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
disable: true
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
nginx:
|
|
image: nginx:1.27.4-alpine
|
|
ports:
|
|
- "127.0.0.1:18081:80"
|
|
volumes:
|
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1/health/live || exit 1"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 10
|
|
restart: unless-stopped
|
|
networks:
|
|
- backend
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
rabbitmq_data:
|
|
seaweedfs_data:
|
|
|
|
networks:
|
|
backend:
|
|
driver: bridge
|