97 lines
2.4 KiB
YAML
97 lines
2.4 KiB
YAML
x-app-image: &app-image
|
|
image: bruh-lab3-api:local
|
|
build: .
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:17.6-bookworm
|
|
environment:
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run python scripts/init-env.py}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
networks: [storage]
|
|
cpus: 1.0
|
|
mem_limit: 512m
|
|
healthcheck:
|
|
test: ["CMD", "pg_isready", "-h", "127.0.0.1", "-U", "messenger", "-d", "messenger"]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 15
|
|
|
|
redis:
|
|
image: redis:7.4.6-bookworm
|
|
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "always", "--save", ""]
|
|
volumes:
|
|
- redis_data:/data
|
|
networks: [storage]
|
|
cpus: 0.5
|
|
mem_limit: 128m
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 15
|
|
|
|
migrate:
|
|
<<: *app-image
|
|
environment:
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run python scripts/init-env.py}
|
|
command: ["python", "-m", "messenger.migrate"]
|
|
healthcheck:
|
|
disable: true
|
|
networks: [storage]
|
|
cpus: 0.5
|
|
mem_limit: 128m
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
|
|
api:
|
|
<<: *app-image
|
|
scale: ${API_REPLICAS:-2}
|
|
environment:
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run python scripts/init-env.py}
|
|
CURSOR_SECRET: ${CURSOR_SECRET:?Run python scripts/init-env.py}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
|
|
SHUTDOWN_TIMEOUT_SECONDS: "4"
|
|
dns_opt: ["timeout:1", "attempts:1"]
|
|
stop_grace_period: 7s
|
|
networks: [edge, storage]
|
|
cpus: 1.0
|
|
mem_limit: 384m
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
redis:
|
|
condition: service_healthy
|
|
|
|
lb:
|
|
image: haproxy:3.2.12-alpine
|
|
volumes:
|
|
- ./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
ports:
|
|
- "127.0.0.1:${APP_PORT:-8081}:8080"
|
|
networks: [edge]
|
|
cpus: 0.5
|
|
mem_limit: 96m
|
|
depends_on:
|
|
api:
|
|
condition: service_started
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/ready"]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 15
|
|
|
|
networks:
|
|
edge:
|
|
storage:
|
|
internal: true
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|