forked from mtusi2026/mtusi2026lab6
333 lines
9.6 KiB
YAML
333 lines
9.6 KiB
YAML
services:
|
||
postgres:
|
||
image: postgres:16-alpine
|
||
environment:
|
||
POSTGRES_DB: messenger
|
||
POSTGRES_USER: messenger
|
||
POSTGRES_PASSWORD: messenger_password
|
||
volumes:
|
||
- postgres_data:/var/lib/postgresql/data
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U messenger"]
|
||
interval: 5s
|
||
timeout: 5s
|
||
retries: 5
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '1.00'
|
||
memory: 512M
|
||
|
||
redis:
|
||
image: redis:7-alpine
|
||
# LAB 5: брокер durable — AOF с fsync раз в секунду.
|
||
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"]
|
||
volumes:
|
||
- redis_data:/data
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "ping"]
|
||
interval: 5s
|
||
timeout: 3s
|
||
retries: 5
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 128M
|
||
|
||
rustfs:
|
||
image: rustfs/rustfs@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
|
||
environment:
|
||
RUSTFS_ACCESS_KEY: ${S3_ACCESS_KEY:-minioadmin}
|
||
RUSTFS_SECRET_KEY: ${S3_SECRET_KEY:-minioadmin}
|
||
RUSTFS_ADDRESS: 0.0.0.0:9000
|
||
RUSTFS_CONSOLE_ADDRESS: 127.0.0.1:9001
|
||
RUSTFS_DATA_DIR: /data
|
||
MINIO_ROOT_USER: ${S3_ACCESS_KEY:-minioadmin}
|
||
MINIO_ROOT_PASSWORD: ${S3_SECRET_KEY:-minioadmin}
|
||
volumes:
|
||
- rustfs_data:/data
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 256M
|
||
|
||
# Однократный сервис миграций: применяется ОДИН РАЗ перед стартом реплик.
|
||
migrate:
|
||
build:
|
||
context: .
|
||
dockerfile: Dockerfile
|
||
entrypoint: ["/app/server", "-migrate-only"]
|
||
depends_on:
|
||
postgres:
|
||
condition: service_healthy
|
||
environment:
|
||
DATABASE_URL: postgres://messenger:messenger_password@postgres:5432/messenger?sslmode=disable
|
||
healthcheck:
|
||
disable: true
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 128M
|
||
|
||
api:
|
||
build:
|
||
context: .
|
||
dockerfile: Dockerfile
|
||
deploy:
|
||
replicas: 2
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 256M
|
||
depends_on:
|
||
migrate:
|
||
condition: service_completed_successfully
|
||
postgres:
|
||
condition: service_healthy
|
||
redis:
|
||
condition: service_healthy
|
||
rustfs:
|
||
condition: service_started
|
||
# LAB 6: Collector поднимается раньше, чтобы первые спаны не терялись.
|
||
# Условие service_started (не healthy): образ Collector без shell,
|
||
# healthcheck внутри контейнера невозможен — готовность проверяем
|
||
# с хоста на http://localhost:13133/.
|
||
otel:
|
||
condition: service_started
|
||
environment:
|
||
APP_HOST: 0.0.0.0
|
||
APP_PORT: 8080
|
||
DATABASE_URL: postgres://messenger:messenger_password@postgres:5432/messenger?sslmode=disable
|
||
REDIS_URL: redis://redis:6379/0
|
||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||
CACHE_MODE: ${CACHE_MODE:-versioned}
|
||
SESSION_STORE: ${SESSION_STORE:-redis}
|
||
S3_ENDPOINT: rustfs:9000
|
||
S3_ACCESS_KEY: ${S3_ACCESS_KEY:-minioadmin}
|
||
S3_SECRET_KEY: ${S3_SECRET_KEY:-minioadmin}
|
||
S3_BUCKET: ${S3_BUCKET:-messenger}
|
||
S3_USE_SSL: "false"
|
||
# LAB 6: телеметрия
|
||
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel:4318
|
||
OTEL_SERVICE_VERSION: lab6
|
||
OTEL_ENV: lab
|
||
healthcheck:
|
||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health/ready"]
|
||
interval: 2s
|
||
timeout: 2s
|
||
retries: 3
|
||
start_period: 5s
|
||
|
||
# LAB 5: отдельный процесс обработки. Не принимает HTTP.
|
||
worker:
|
||
build:
|
||
context: .
|
||
dockerfile: Dockerfile
|
||
entrypoint: ["/app/server", "-worker"]
|
||
deploy:
|
||
replicas: 1
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 512M
|
||
depends_on:
|
||
migrate:
|
||
condition: service_completed_successfully
|
||
postgres:
|
||
condition: service_healthy
|
||
redis:
|
||
condition: service_healthy
|
||
rustfs:
|
||
condition: service_started
|
||
otel:
|
||
condition: service_started
|
||
environment:
|
||
DATABASE_URL: postgres://messenger:messenger_password@postgres:5432/messenger?sslmode=disable
|
||
REDIS_URL: redis://redis:6379/0
|
||
S3_ENDPOINT: rustfs:9000
|
||
S3_ACCESS_KEY: ${S3_ACCESS_KEY:-minioadmin}
|
||
S3_SECRET_KEY: ${S3_SECRET_KEY:-minioadmin}
|
||
S3_BUCKET: ${S3_BUCKET:-messenger}
|
||
S3_USE_SSL: "false"
|
||
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel:4318
|
||
OTEL_SERVICE_VERSION: lab6
|
||
OTEL_ENV: lab
|
||
healthcheck:
|
||
disable: true
|
||
|
||
# LAB 5 (уровень 4): ручная сверка S3 <-> PostgreSQL.
|
||
reconcile:
|
||
build:
|
||
context: .
|
||
dockerfile: Dockerfile
|
||
entrypoint: ["/app/server", "-reconcile"]
|
||
depends_on:
|
||
postgres:
|
||
condition: service_healthy
|
||
rustfs:
|
||
condition: service_started
|
||
environment:
|
||
DATABASE_URL: postgres://messenger:messenger_password@postgres:5432/messenger?sslmode=disable
|
||
S3_ENDPOINT: rustfs:9000
|
||
S3_ACCESS_KEY: ${S3_ACCESS_KEY:-minioadmin}
|
||
S3_SECRET_KEY: ${S3_SECRET_KEY:-minioadmin}
|
||
S3_BUCKET: ${S3_BUCKET:-messenger}
|
||
S3_USE_SSL: "false"
|
||
RECONCILE_GRACE_PERIOD_SECONDS: ${RECONCILE_GRACE_PERIOD_SECONDS:-3600}
|
||
profiles:
|
||
- tools
|
||
healthcheck:
|
||
disable: true
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 128M
|
||
|
||
nginx:
|
||
image: nginx:1.25-alpine
|
||
ports:
|
||
- "8080:8080"
|
||
depends_on:
|
||
api:
|
||
condition: service_healthy
|
||
volumes:
|
||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.25'
|
||
memory: 64M
|
||
|
||
# ─────────────────── LAB 6: наблюдаемость ───────────────────
|
||
|
||
# Приёмник/обработчик/экспортёр. Не долговременное хранилище.
|
||
# memory_limiter 128 MiB при лимите контейнера 256M — запас на пики.
|
||
otel:
|
||
image: otel/opentelemetry-collector-contrib:0.115.1
|
||
command: ["--config=/etc/otel/config.yaml"]
|
||
volumes:
|
||
- ./otel-collector.yaml:/etc/otel/config.yaml:ro
|
||
ports:
|
||
- "4318:4318" # OTLP/HTTP (API и worker шлют сюда)
|
||
- "8889:8889" # метрики приложения (Prometheus exporter)
|
||
- "8888:8888" # собственные метрики Collector
|
||
- "13133:13133" # health_check extension
|
||
depends_on:
|
||
prometheus:
|
||
condition: service_started
|
||
loki:
|
||
condition: service_started
|
||
tempo:
|
||
condition: service_started
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 256M
|
||
|
||
prometheus:
|
||
image: prom/prometheus:v2.55.1
|
||
command:
|
||
- "--config.file=/etc/prometheus/prometheus.yaml"
|
||
- "--storage.tsdb.path=/prometheus"
|
||
- "--storage.tsdb.retention.time=6h"
|
||
- "--storage.tsdb.retention.size=512MB"
|
||
- "--web.enable-lifecycle"
|
||
volumes:
|
||
- ./prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
|
||
- prometheus_data:/prometheus
|
||
ports:
|
||
- "9090:9090"
|
||
healthcheck:
|
||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
|
||
interval: 5s
|
||
timeout: 3s
|
||
retries: 10
|
||
start_period: 10s
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 384M
|
||
|
||
loki:
|
||
image: grafana/loki:3.3.2
|
||
command: ["-config.file=/etc/loki/config.yaml"]
|
||
volumes:
|
||
- ./loki.yaml:/etc/loki/config.yaml:ro
|
||
- loki_data:/loki
|
||
ports:
|
||
- "3100:3100"
|
||
healthcheck:
|
||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3100/ready"]
|
||
interval: 5s
|
||
timeout: 3s
|
||
retries: 20
|
||
start_period: 20s
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 384M
|
||
|
||
tempo:
|
||
image: grafana/tempo:2.6.1
|
||
command: ["-config.file=/etc/tempo/config.yaml"]
|
||
volumes:
|
||
- ./tempo.yaml:/etc/tempo/config.yaml:ro
|
||
- tempo_data:/var/tempo
|
||
ports:
|
||
- "3200:3200"
|
||
# Образ Tempo без гарантированного shell/wget — healthcheck не задаём,
|
||
# готовность проверяем с хоста: curl http://localhost:3200/ready
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 384M
|
||
|
||
grafana:
|
||
image: grafana/grafana:11.4.0
|
||
environment:
|
||
GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:-admin}
|
||
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:-admin}
|
||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||
GF_FEATURE_TOGGLES_ENABLE: "traceqlEditor"
|
||
volumes:
|
||
- ./grafana/provisioning:/etc/grafana/provisioning:ro
|
||
- grafana_data:/var/lib/grafana
|
||
ports:
|
||
- "3000:3000"
|
||
depends_on:
|
||
prometheus:
|
||
condition: service_healthy
|
||
loki:
|
||
condition: service_healthy
|
||
tempo:
|
||
condition: service_started
|
||
healthcheck:
|
||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
||
interval: 5s
|
||
timeout: 3s
|
||
retries: 20
|
||
start_period: 20s
|
||
deploy:
|
||
resources:
|
||
limits:
|
||
cpus: '0.50'
|
||
memory: 256M
|
||
|
||
volumes:
|
||
postgres_data:
|
||
redis_data:
|
||
rustfs_data:
|
||
prometheus_data:
|
||
loki_data:
|
||
tempo_data:
|
||
grafana_data: |