Files
2026-11-18 21:37:25 +03:00

251 lines
7.0 KiB
YAML

name: mtusi2026lab6
services:
postgres:
image: postgres:17.6-alpine3.22
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_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.5-alpine3.21
command: [redis-server, /usr/local/etc/redis/redis.conf]
volumes:
- redis_data:/data
- ./infra/redis.conf:/usr/local/etc/redis/redis.conf:ro
healthcheck:
test: [CMD, redis-cli, ping]
interval: 2s
timeout: 2s
retries: 30
cpus: 0.5
mem_limit: 384m
minio:
environment:
GOMEMLIMIT: 160MiB
GOGC: '50'
image: mtusi-minio:RELEASE.2025-09-07T16-13-09Z
build:
context: .
dockerfile: Dockerfile.storage
target: minio
secrets: [s3_root_access_key, s3_root_secret_key]
volumes: [s3_data:/data]
healthcheck:
test: [CMD, wget, -q, -T, '2', -O, /dev/null, 'http://127.0.0.1:9000/minio/health/live']
interval: 2s
timeout: 3s
start_period: 15s
retries: 30
cpus: 1.0
mem_limit: 512m
stop_grace_period: 20s
s3_bootstrap:
image: mtusi-mc:RELEASE.2025-08-13T08-35-41Z
build:
context: .
dockerfile: Dockerfile.storage
target: mc
entrypoint: [/bin/sh, /bootstrap.sh]
configs:
- source: s3_bootstrap
target: /bootstrap.sh
- source: s3_policy
target: /policy.json
secrets: [s3_root_access_key, s3_root_secret_key, s3_access_key, s3_secret_key]
depends_on:
minio:
condition: service_healthy
cpus: 0.5
mem_limit: 512m
migrations:
image: mtusi-migrations:lab6
build:
context: .
target: migrations
environment:
GOOSE_DRIVER: postgres
GOOSE_DBSTRING: host=postgres user=messenger dbname=messenger sslmode=disable connect_timeout=5
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_password
depends_on:
postgres:
condition: service_healthy
cpus: 0.5
mem_limit: 128m
api:
build: .
image: mtusi-messenger:lab6
environment: &api_environment
POSTGRES_HOST: postgres
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
POSTGRES_MAX_CONNS: '10'
REDIS_ADDR: redis:6379
CURSOR_KEY_FILE: /run/secrets/cursor_key
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
QUERY_TIMEOUT_MS: '2000'
S3_ENDPOINT: minio:9000
S3_BUCKET: attachments
S3_ACCESS_KEY_FILE: /run/secrets/s3_access_key
S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key
S3_USE_SSL: 'false'
GOMEMLIMIT: 384MiB
OTEL_EXPORTER_OTLP_ENDPOINT: http://collector:4318
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
OTEL_SDK_DISABLED: ${OTEL_SDK_DISABLED:-false}
OTEL_TRACES_SAMPLER: parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG: ${OTEL_TRACES_SAMPLER_ARG:-1.0}
GOGC: '50'
secrets: &api_secrets
- postgres_password
- cursor_key
- s3_access_key
- s3_secret_key
deploy:
replicas: 2
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
s3_bootstrap:
condition: service_completed_successfully
cpus: 1.0
mem_limit: 512m
stop_grace_period: 10s
worker:
image: mtusi-messenger:lab6
build: .
entrypoint: [/usr/local/bin/worker]
environment:
<<: *api_environment
WORKER_CONCURRENCY: '2'
WORKER_PREFETCH: '4'
WORKER_MAX_ATTEMPTS: '5'
WORKER_TIMEOUT_SECONDS: '25'
WORKER_LEASE_SECONDS: '40'
WORKER_PIXEL_BUDGET: '40000000'
secrets: *api_secrets
healthcheck: {disable: true}
depends_on:
migrations: {condition: service_completed_successfully}
s3_bootstrap: {condition: service_completed_successfully}
redis: {condition: service_healthy}
cpus: 1.0
mem_limit: 512m
stop_grace_period: 10s
gateway:
image: haproxy:3.2.4-alpine
ports: ['127.0.0.1:${PORT:-18086}:8080']
volumes: [./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro]
depends_on: [api]
mem_limit: 64m
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]
mem_limit: 192m
depends_on: [tempo, loki, prometheus]
prometheus:
image: prom/prometheus:v3.6.0
command: [--config.file=/etc/prometheus/prometheus.yaml, --storage.tsdb.retention.time=7d, --storage.tsdb.retention.size=1GB, --web.enable-remote-write-receiver]
ports: ['127.0.0.1:19090:9090']
volumes:
- ./infra/prometheus:/etc/prometheus:ro
- prometheus_data:/prometheus
mem_limit: 256m
loki:
image: grafana/loki:3.5.5
command: [-config.file=/etc/loki/config.yaml]
ports: ['127.0.0.1:13100:3100']
volumes:
- ./infra/loki.yaml:/etc/loki/config.yaml:ro
- loki_data:/loki
mem_limit: 192m
tempo:
image: grafana/tempo:2.8.2
command: [-config.file=/etc/tempo/config.yaml]
ports: ['127.0.0.1:13200:3200']
volumes:
- ./infra/tempo.yaml:/etc/tempo/config.yaml:ro
- tempo_data:/var/tempo
environment:
GOMEMLIMIT: 320MiB
GOGC: '50'
mem_limit: 512m
grafana:
image: grafana/grafana:12.2.0
ports: ['127.0.0.1:13000:3000']
environment:
GF_PLUGINS_PREINSTALL_DISABLED: 'true'
GF_ANALYTICS_CHECK_FOR_UPDATES: 'false'
GF_ANALYTICS_REPORTING_ENABLED: 'false'
GF_AUTH_ANONYMOUS_ENABLED: 'true'
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
GF_USERS_ALLOW_SIGN_UP: 'false'
volumes:
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
- grafana_data:/var/lib/grafana
mem_limit: 192m
depends_on: [prometheus, loki, tempo]
tests:
image: mtusi-messenger-tests:lab6
profiles: [test]
build:
context: .
target: tests
environment:
<<: *api_environment
INTEGRATION_TESTS: '1'
secrets: *api_secrets
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
cpus: 1.0
mem_limit: 1g
configs:
s3_bootstrap:
file: ./infra/s3-bootstrap.sh
s3_policy:
file: ./infra/s3-policy.json
secrets:
s3_root_access_key:
file: ./secrets/s3_root_access_key
s3_root_secret_key:
file: ./secrets/s3_root_secret_key
s3_access_key:
file: ./secrets/s3_access_key
s3_secret_key:
file: ./secrets/s3_secret_key
postgres_password:
file: ./secrets/postgres_password
cursor_key:
file: ./secrets/cursor_key
volumes:
postgres_data:
redis_data:
s3_data:
prometheus_data:
loki_data:
tempo_data:
grafana_data: