334 lines
9.5 KiB
YAML
334 lines
9.5 KiB
YAML
services:
|
|
lb:
|
|
image: haproxy:2.9-alpine
|
|
ports:
|
|
- "127.0.0.1:8080:8080"
|
|
volumes:
|
|
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "haproxy", "-c", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 3
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.25"
|
|
memory: 64M
|
|
restart: unless-stopped
|
|
|
|
api:
|
|
build: .
|
|
expose:
|
|
- "8080"
|
|
environment:
|
|
PORT: "8080"
|
|
DATABASE_URL: postgres://${PG_USER}:${PG_PASSWORD}@postgres:5432/${PG_DB}?sslmode=disable&timezone=UTC
|
|
REDIS_URL: redis://redis:6379/0
|
|
BROKER_URL: redis://broker:6379/1
|
|
SESSION_TTL_SECONDS: "${SESSION_TTL_SECONDS:-3600}"
|
|
IDEMPOTENCY_TTL_SECONDS: "${IDEMPOTENCY_TTL_SECONDS:-86400}"
|
|
S3_ENDPOINT: "${S3_ENDPOINT:-http://s3:9000}"
|
|
S3_REGION: "${S3_REGION:-us-east-1}"
|
|
S3_BUCKET: "${S3_BUCKET:-messenger-attachments}"
|
|
S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID}"
|
|
S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY}"
|
|
S3_USE_SSL: "${S3_USE_SSL:-false}"
|
|
MAX_UPLOAD_BYTES: "${MAX_UPLOAD_BYTES:-10485760}"
|
|
MAX_IMAGE_PIXELS: "${MAX_IMAGE_PIXELS:-40000000}"
|
|
ATTACHMENT_GRACE_SECONDS: "${ATTACHMENT_GRACE_SECONDS:-600}"
|
|
JOB_MAX_ATTEMPTS: "${JOB_MAX_ATTEMPTS:-5}"
|
|
# Observability (Lab 6)
|
|
OTEL_SERVICE_NAME: "messenger-api"
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otelcol:4317"
|
|
OTEL_TRACES_EXPORTER: "otlp"
|
|
OTEL_METRICS_EXPORTER: "otlp"
|
|
OTEL_LOGS_EXPORTER: "otlp"
|
|
OTEL_RESOURCE_ATTRIBUTES: "service.name=messenger-api,service.version=lab6,deployment.environment=dev"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
broker:
|
|
condition: service_healthy
|
|
s3:
|
|
condition: service_started
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/health/ready"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
start_period: 15s
|
|
retries: 5
|
|
deploy:
|
|
replicas: 2
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 512M
|
|
restart: unless-stopped
|
|
|
|
worker:
|
|
build: .
|
|
command: ["./worker"]
|
|
environment:
|
|
DATABASE_URL: postgres://${PG_USER}:${PG_PASSWORD}@postgres:5432/${PG_DB}?sslmode=disable&timezone=UTC
|
|
REDIS_URL: redis://broker:6379/1
|
|
S3_ENDPOINT: "${S3_ENDPOINT:-http://s3:9000}"
|
|
S3_REGION: "${S3_REGION:-us-east-1}"
|
|
S3_BUCKET: "${S3_BUCKET:-messenger-attachments}"
|
|
S3_ACCESS_KEY_ID: "${S3_ACCESS_KEY_ID}"
|
|
S3_SECRET_ACCESS_KEY: "${S3_SECRET_ACCESS_KEY}"
|
|
S3_USE_SSL: "${S3_USE_SSL:-false}"
|
|
MAX_UPLOAD_BYTES: "${MAX_UPLOAD_BYTES:-10485760}"
|
|
MAX_IMAGE_PIXELS: "${MAX_IMAGE_PIXELS:-40000000}"
|
|
JOB_MAX_ATTEMPTS: "${JOB_MAX_ATTEMPTS:-5}"
|
|
JOB_CONCURRENCY: "${JOB_CONCURRENCY:-2}"
|
|
JOB_LEASE_SECONDS: "${JOB_LEASE_SECONDS:-90}"
|
|
JOB_TIMEOUT_SECONDS: "${JOB_TIMEOUT_SECONDS:-60}"
|
|
JOB_POLL_SECONDS: "${JOB_POLL_SECONDS:-5}"
|
|
JOB_RECLAIM_IDLE_SECONDS: "${JOB_RECLAIM_IDLE_SECONDS:-15}"
|
|
STAGING_RETENTION_SECONDS: "${STAGING_RETENTION_SECONDS:-300}"
|
|
FAULT_EXIT_AT: "${FAULT_EXIT_AT:-}"
|
|
FAULT_FAIL_MODE: "${FAULT_FAIL_MODE:-}"
|
|
FAULT_FAIL_TIMES: "${FAULT_FAIL_TIMES:-1000000}"
|
|
# Observability (Lab 6)
|
|
OTEL_SERVICE_NAME: "messenger-worker"
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otelcol:4317"
|
|
OTEL_TRACES_EXPORTER: "otlp"
|
|
OTEL_METRICS_EXPORTER: "otlp"
|
|
OTEL_LOGS_EXPORTER: "otlp"
|
|
OTEL_RESOURCE_ATTRIBUTES: "service.name=messenger-worker,service.version=lab6,deployment.environment=dev"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
broker:
|
|
condition: service_healthy
|
|
s3:
|
|
condition: service_started
|
|
healthcheck:
|
|
disable: true
|
|
deploy:
|
|
replicas: 1
|
|
resources:
|
|
limits:
|
|
cpus: "1.0"
|
|
memory: 512M
|
|
restart: unless-stopped
|
|
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: ${PG_USER}
|
|
POSTGRES_PASSWORD: ${PG_PASSWORD}
|
|
POSTGRES_DB: ${PG_DB}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${PG_USER} -d ${PG_DB}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 256M
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
command: >
|
|
redis-server
|
|
--appendonly yes
|
|
--appendfsync everysec
|
|
--auto-aof-rewrite-percentage 100
|
|
--auto-aof-rewrite-min-size 64mb
|
|
--maxmemory 128mb
|
|
--maxmemory-policy noeviction
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.25"
|
|
memory: 192M
|
|
restart: unless-stopped
|
|
|
|
broker:
|
|
image: redis:7-alpine
|
|
command: >
|
|
redis-server
|
|
--appendonly yes
|
|
--appendfsync everysec
|
|
--maxmemory 256mb
|
|
--maxmemory-policy noeviction
|
|
volumes:
|
|
- broker_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 256M
|
|
restart: unless-stopped
|
|
|
|
s3:
|
|
image: rustfs/rustfs@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
|
|
command: ["server", "--address", ":9000"]
|
|
environment:
|
|
RUSTFS_ADDRESS: ":9000"
|
|
RUSTFS_VOLUMES: "/data"
|
|
RUSTFS_REGION: "${S3_REGION:-us-east-1}"
|
|
RUSTFS_ROOT_USER: "${S3_ROOT_USER:-minioadmin}"
|
|
RUSTFS_ROOT_PASSWORD: "${S3_ROOT_PASSWORD:-minioadmin-change-me-123}"
|
|
RUSTFS_CONSOLE_ENABLE: "false"
|
|
RUSTFS_OBS_LOGGER_LEVEL: "warn"
|
|
volumes:
|
|
- s3_data:/data
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 256M
|
|
restart: unless-stopped
|
|
|
|
prometheus:
|
|
image: prom/prometheus:v2.55.0
|
|
command:
|
|
- --config.file=/etc/prometheus/prometheus.yml
|
|
- --storage.tsdb.path=/prometheus
|
|
- --storage.tsdb.retention.time=2h
|
|
- --web.enable-lifecycle
|
|
volumes:
|
|
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
- ./infra/prometheus/rules.yml:/etc/prometheus/rules.yml:ro
|
|
- prometheus_data:/prometheus
|
|
ports:
|
|
- "127.0.0.1:9090:9090"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:9090/-/healthy || exit 1"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 256M
|
|
restart: unless-stopped
|
|
|
|
loki:
|
|
image: grafana/loki:3.2.0
|
|
command: -config.file=/etc/loki/local-config.yaml
|
|
volumes:
|
|
- ./infra/loki/loki-config.yaml:/etc/loki/local-config.yaml:ro
|
|
- loki_data:/loki
|
|
ports:
|
|
- "127.0.0.1:3100:3100"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 30s
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 384M
|
|
restart: unless-stopped
|
|
|
|
tempo:
|
|
image: grafana/tempo:2.6.0
|
|
user: "10001:10001"
|
|
command: -config.file=/etc/tempo.yaml
|
|
volumes:
|
|
- ./infra/tempo/tempo.yaml:/etc/tempo.yaml:ro
|
|
ports:
|
|
- "127.0.0.1:3200:3200"
|
|
healthcheck:
|
|
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3200/ready || exit 1" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 30s
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 384M
|
|
restart: unless-stopped
|
|
|
|
otelcol:
|
|
image: otel/opentelemetry-collector-contrib:0.112.0
|
|
command: ["--config=/etc/otelcol/config.yaml"]
|
|
volumes:
|
|
- ./infra/otelcol/config.yaml:/etc/otelcol/config.yaml:ro
|
|
ports:
|
|
- "127.0.0.1:4317:4317"
|
|
- "127.0.0.1:4318:4318"
|
|
- "127.0.0.1:8888:8888"
|
|
- "127.0.0.1:8889:8889"
|
|
- "127.0.0.1:13133:13133"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8889/health || exit 1"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 20s
|
|
disable: true
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 256M
|
|
restart: unless-stopped
|
|
|
|
grafana:
|
|
image: grafana/grafana:11.2.0
|
|
environment:
|
|
GF_SECURITY_ADMIN_USER: admin
|
|
GF_SECURITY_ADMIN_PASSWORD: admin
|
|
GF_USERS_ALLOW_SIGN_UP: "false"
|
|
GF_AUTH_ANONYMOUS_ENABLED: "true"
|
|
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
|
|
volumes:
|
|
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
|
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
|
- grafana_data:/var/lib/grafana
|
|
ports:
|
|
- "127.0.0.1:3000:3000"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 20s
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.50"
|
|
memory: 256M
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
s3_data:
|
|
broker_data:
|
|
prometheus_data:
|
|
loki_data:
|
|
grafana_data: |