forked from mtusi2026/mtusi2026lab4
78 lines
2.0 KiB
YAML
78 lines
2.0 KiB
YAML
name: messenger-lab4
|
|
x-api: &api
|
|
build: .
|
|
environment: &environment
|
|
LAB_NUMBER: "4"
|
|
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
S3_ENDPOINT: http://s3:8333
|
|
S3_ACCESS_KEY: ${S3_ACCESS_KEY}
|
|
S3_SECRET_KEY: ${S3_SECRET_KEY}
|
|
S3_BUCKET: ${S3_BUCKET}
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
bucket-init:
|
|
condition: service_completed_successfully
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/ready', timeout=3)"]
|
|
interval: 3s
|
|
timeout: 5s
|
|
retries: 5
|
|
stop_grace_period: 10s
|
|
mem_limit: 512m
|
|
cpus: 1.0
|
|
services:
|
|
postgres:
|
|
image: postgres:16.8-alpine
|
|
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: 2s
|
|
timeout: 3s
|
|
retries: 30
|
|
migrate:
|
|
build: .
|
|
environment: *environment
|
|
command: ["python", "-m", "app.migrate"]
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
api1:
|
|
<<: *api
|
|
api2:
|
|
<<: *api
|
|
lb:
|
|
image: haproxy:3.0.10-alpine
|
|
ports:
|
|
- "127.0.0.1:${PUBLIC_PORT}:8080"
|
|
volumes:
|
|
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
depends_on:
|
|
api1:
|
|
condition: service_healthy
|
|
api2:
|
|
condition: service_healthy
|
|
s3:
|
|
image: chrislusf/seaweedfs:3.85
|
|
working_dir: /data
|
|
command: server -dir=/data -ip=s3 -filer -s3 -s3.config=/etc/seaweedfs/s3.json -volume.max=5 -master.volumeSizeLimitMB=100
|
|
volumes:
|
|
- s3_data:/data
|
|
- ./infra/s3.json:/etc/seaweedfs/s3.json:ro
|
|
bucket-init:
|
|
build: .
|
|
environment: *environment
|
|
command: ["python", "-m", "app.bucket_init"]
|
|
depends_on:
|
|
- s3
|
|
|
|
volumes:
|
|
postgres_data:
|
|
s3_data:
|