Files
mtusi2026lab3/compose.yaml
DaniilKuznetsovandЮгай Артур Рустамович 09aece58fe ЛР3 на 3
Co-authored-by: Югай Артур Рустамович <f1ekserr@yandex.ru>
2026-11-16 22:23:04 +03:00

83 lines
1.9 KiB
YAML

name: kuznetsov-lab3
x-app: &app
image: mtusi-messenger:kuznetsov-lab3
build: .
environment:
APP_HOST: 0.0.0.0
APP_PORT: 8080
APP_ENV: lab
DATABASE_URL_FILE: /run/secrets/database_url
CURSOR_SECRET_FILE: /run/secrets/cursor_key
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
secrets:
- database_url
- cursor_key
stop_grace_period: 3s
services:
db:
image: postgres:17.11-bookworm@sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_password
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
interval: 2s
timeout: 3s
retries: 30
stop_grace_period: 10s
migrate:
<<: *app
command: ["python", "-m", "src.migrate"]
depends_on:
db:
condition: service_healthy
api1:
<<: *app
depends_on:
db:
condition: service_healthy
migrate:
condition: service_completed_successfully
api2:
<<: *app
depends_on:
db:
condition: service_healthy
migrate:
condition: service_completed_successfully
lb:
image: haproxy:3.2.26@sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953
ports:
- "127.0.0.1:${HTTP_PORT:-18103}:8080"
volumes:
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on:
api1:
condition: service_started
api2:
condition: service_started
stop_grace_period: 3s
volumes:
pgdata:
secrets:
postgres_password:
file: ./secrets/postgres_password
database_url:
file: ./secrets/database_url
cursor_key:
file: ./secrets/cursor_key