Files
mtusi2026lab5_fork/docker-compose.yml
T
2026-11-12 18:48:39 +03:00

198 lines
5.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}"
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}"
STAGING_RETENTION_SECONDS: "${STAGING_RETENTION_SECONDS:-300}"
JOB_RECLAIM_IDLE_SECONDS: "${JOB_RECLAIM_IDLE_SECONDS:-15}"
FAULT_EXIT_AT: "${FAULT_EXIT_AT:-}"
FAULT_FAIL_MODE: "${FAULT_FAIL_MODE:-}"
FAULT_FAIL_TIMES: "${FAULT_FAIL_TIMES:-1000000}"
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
volumes:
postgres_data:
redis_data:
s3_data:
broker_data: