Files
mtusi2026lab5/compose.yaml
T

178 lines
4.8 KiB
YAML

name: lyakhonov-lab5
x-app: &app
image: lyakhonov-messenger:lab5
build: .
environment:
DATABASE_URL_FILE: /run/secrets/database_url
S3_ENDPOINT: http://s3:9000
S3_ACCESS_KEY_FILE: /run/secrets/s3_access_key
S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-60}
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-90}
LAB5_FAULT_INJECTION: ${LAB5_FAULT_INJECTION:-0}
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
CACHE_URL: redis://redis:6379/0
BROKER_URL_FILE: /run/secrets/broker_url
secrets: [database_url, s3_access_key, s3_secret_key, broker_url]
cpus: 0.5
mem_limit: 640m
stop_grace_period: 12s
x-dependencies: &dependencies
migrate:
condition: service_completed_successfully
bucket-init:
condition: service_completed_successfully
services:
inspector:
<<: *app
profiles: [tools]
environment:
DATABASE_URL_FILE: /run/secrets/database_url
S3_ENDPOINT: http://s3:9000
S3_ACCESS_KEY_FILE: /run/secrets/s3_root_user
S3_SECRET_KEY_FILE: /run/secrets/s3_root_password
secrets: [database_url, s3_root_user, s3_root_password]
healthcheck:
disable: true
cpus: 0.25
mem_limit: 256m
db:
image: postgres:16.6-alpine
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets: [db_password]
volumes: [postgres_data:/var/lib/postgresql/data]
healthcheck:
test: [CMD-SHELL, 'pg_isready -U messenger -d messenger']
interval: 2s
timeout: 2s
retries: 30
cpus: 1.0
mem_limit: 512m
redis:
image: redis:7.4.1-alpine
command: [redis-server, --maxmemory, 64mb, --maxmemory-policy, allkeys-lru, --save, "", --appendonly, "no"]
cpus: 0.25
mem_limit: 128m
s3:
image: lyakhonov-storage:lab5
build:
context: .
dockerfile: Dockerfile.s3
command: [server, /data, --console-address, '127.0.0.1:9001']
environment:
MINIO_ROOT_USER_FILE: /run/secrets/s3_root_user
MINIO_ROOT_PASSWORD_FILE: /run/secrets/s3_root_password
secrets: [s3_root_user, s3_root_password]
volumes: [s3_data:/data]
cpus: 1.0
mem_limit: 768m
bucket-init:
image: lyakhonov-storage:lab5
pull_policy: never
entrypoint: [/bin/sh, /bootstrap/bucket.sh]
secrets: [s3_root_user, s3_root_password, s3_access_key, s3_secret_key]
volumes: [./infra/bucket.sh:/bootstrap/bucket.sh:ro, ./infra/s3-policy.json:/bootstrap/policy.json:ro]
depends_on: [s3]
cpus: 0.25
mem_limit: 128m
broker:
image: rabbitmq:4.1.0-alpine
hostname: broker
entrypoint: [/bin/sh, /bootstrap/broker.sh]
volumes: [broker_data:/var/lib/rabbitmq, ./infra/broker.sh:/bootstrap/broker.sh:ro,
./infra/rabbitmq.conf:/etc/rabbitmq/conf.d/90-lab5.conf:ro]
secrets: [broker_password]
healthcheck:
test: [CMD, rabbitmq-diagnostics, -q, ping]
interval: 5s
timeout: 4s
retries: 20
cpus: 0.75
mem_limit: 512m
migrate:
<<: *app
command: [python, -m, src.migrate]
depends_on:
db:
condition: service_healthy
healthcheck:
disable: true
api:
<<: *app
depends_on: *dependencies
deploy:
replicas: ${API_REPLICAS:-2}
dispatcher:
<<: *app
command: [python, -m, src.dispatch]
restart: unless-stopped
depends_on:
<<: *dependencies
broker:
condition: service_healthy
healthcheck:
disable: true
mem_limit: 256m
worker:
<<: *app
command: [python, -m, src.worker]
restart: unless-stopped
depends_on:
<<: *dependencies
broker:
condition: service_healthy
healthcheck:
disable: true
deploy:
replicas: ${WORKER_CONCURRENCY:-2}
cpus: 0.75
mem_limit: 768m
stop_grace_period: 95s
staging-cleaner:
<<: *app
command: [python, -m, src.staging]
restart: unless-stopped
depends_on: *dependencies
healthcheck:
disable: true
cpus: 0.25
mem_limit: 256m
lb:
image: haproxy:3.0.6-alpine
ports: ['127.0.0.1:${LAB5_PORT:-8085}:8080']
volumes: [./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro]
depends_on: [api]
cpus: 0.5
mem_limit: 128m
stop_grace_period: 12s
secrets:
s3_root_user:
file: ./secrets/s3_root_user
s3_root_password:
file: ./secrets/s3_root_password
s3_access_key:
file: ./secrets/s3_access_key
s3_secret_key:
file: ./secrets/s3_secret_key
db_password:
file: ./secrets/db_password
database_url:
file: ./secrets/database_url
broker_password:
file: ./secrets/broker_password
broker_url:
file: ./secrets/broker_url
volumes:
postgres_data:
s3_data:
broker_data: