Files
mtusi2026lab6/compose.yaml
T

239 lines
7.0 KiB
YAML

name: lyakhonov-lab6
x-app: &app
image: ${APP_IMAGE:-lyakhonov-messenger:lab6}
environment:
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
TELEMETRY_ENABLED: ${TELEMETRY_ENABLED:-1}
TRACE_SAMPLE_RATIO: ${TRACE_SAMPLE_RATIO:-1}
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:
otel-collector:
image: otel/opentelemetry-collector-contrib:0.137.0
command: [--config=/etc/otelcol/config.yaml]
volumes: [./infra/otel/collector.yaml:/etc/otelcol/config.yaml:ro]
cpus: 0.5
mem_limit: 256m
restart: unless-stopped
prometheus:
image: prom/prometheus:v3.7.3
command: [--config.file=/etc/prometheus/prometheus.yaml, --storage.tsdb.retention.time=24h, --storage.tsdb.retention.size=512MB]
volumes: [./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro, ./infra/otel/alerts.yaml:/etc/prometheus/alerts.yaml:ro, metrics_data:/prometheus]
cpus: 0.5
mem_limit: 384m
restart: unless-stopped
loki:
image: grafana/loki:3.5.7
command: [-config.file=/etc/loki/config.yaml]
volumes: [./infra/otel/loki.yaml:/etc/loki/config.yaml:ro, logs_data:/loki]
cpus: 0.5
mem_limit: 384m
restart: unless-stopped
tempo:
image: grafana/tempo:2.9.0
command: [-config.file=/etc/tempo.yaml]
volumes: [./infra/otel/tempo.yaml:/etc/tempo.yaml:ro, traces_data:/var/tempo]
cpus: 0.5
mem_limit: 384m
restart: unless-stopped
grafana:
image: grafana/grafana:12.2.1
ports: ['127.0.0.1:${GRAFANA_PORT:-3006}:3000']
environment:
GF_AUTH_ANONYMOUS_ENABLED: 'true'
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_password
GF_USERS_ALLOW_SIGN_UP: 'false'
GF_ANALYTICS_REPORTING_ENABLED: 'false'
GF_ANALYTICS_CHECK_FOR_UPDATES: 'false'
secrets: [grafana_password]
volumes: [grafana_data:/var/lib/grafana, ./infra/grafana/provisioning:/etc/grafana/provisioning:ro, ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro]
cpus: 0.5
mem_limit: 384m
restart: unless-stopped
diagnostics:
<<: *app
command: [python, -m, src.diagnostics]
depends_on: *dependencies
healthcheck:
disable: true
cpus: 0.25
mem_limit: 128m
restart: unless-stopped
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: ${S3_IMAGE:-lyakhonov-storage:lab6}
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: ${S3_IMAGE:-lyakhonov-storage:lab6}
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
build: .
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:${LAB6_PORT:-8086}: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:
grafana_password:
file: ./secrets/grafana_password
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:
metrics_data:
logs_data:
traces_data:
grafana_data: