Files
mtusi2026lab4/compose.yaml
T

195 lines
5.0 KiB
YAML

services:
load_balancer:
image: nginx:1.27-alpine
ports:
- "8080:8080"
volumes:
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
api-1:
condition: service_healthy
api-2:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/live"]
interval: 2s
timeout: 2s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 128M
migration:
image: postgres:16-alpine
restart: "no"
environment:
PGPASSWORD: postgres
command: >
sh -c "until pg_isready -h postgres -U postgres -d messenger; do sleep 1; done;
psql -h postgres -U postgres -d messenger -f /docker-entrypoint-initdb.d/init.sql"
volumes:
- ./infra/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
depends_on:
postgres:
condition: service_healthy
deploy:
resources:
limits:
cpus: '0.25'
memory: 128M
api-1:
build:
context: .
dockerfile: Dockerfile
image: highload-messenger:lab4
stop_grace_period: 15s
environment:
APP_HOST: "0.0.0.0"
APP_PORT: "8080"
APP_ENV: "lab"
INSTANCE_ID: "api-1"
SESSION_TTL_SECONDS: "3600"
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/messenger"
SESSION_STORE: "redis"
CACHE_URL: "redis://redis:6379/0"
IDEMPOTENCY_TTL_SECONDS: "86400"
S3_ENDPOINT: "http://minio:9000"
S3_REGION: "us-east-1"
S3_BUCKET: "messenger-attachments"
S3_ACCESS_KEY_ID: "minioadmin"
S3_SECRET_ACCESS_KEY: "minioadmin"
MAX_UPLOAD_BYTES: "10485760"
MAX_IMAGE_PIXELS: "40000000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
migration:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
interval: 2s
timeout: 2s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
api-2:
build:
context: .
dockerfile: Dockerfile
image: highload-messenger:lab4
stop_grace_period: 15s
environment:
APP_HOST: "0.0.0.0"
APP_PORT: "8080"
APP_ENV: "lab"
INSTANCE_ID: "api-2"
SESSION_TTL_SECONDS: "3600"
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/messenger"
SESSION_STORE: "redis"
CACHE_URL: "redis://redis:6379/0"
IDEMPOTENCY_TTL_SECONDS: "86400"
S3_ENDPOINT: "http://minio:9000"
S3_REGION: "us-east-1"
S3_BUCKET: "messenger-attachments"
S3_ACCESS_KEY_ID: "minioadmin"
S3_SECRET_ACCESS_KEY: "minioadmin"
MAX_UPLOAD_BYTES: "10485760"
MAX_IMAGE_PIXELS: "40000000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
migration:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
interval: 2s
timeout: 2s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: messenger
volumes:
- pg_data:/var/lib/postgresql/data
- ./infra/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d messenger"]
interval: 2s
timeout: 2s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
redis:
image: redis:7-alpine
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s
timeout: 2s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.25'
memory: 256M
minio:
image: cleanstart/minio:0.20260330.001845
user: "0:0"
command: server /data --address ":9000" --console-address ":9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:9000/minio/health/live"]
interval: 2s
timeout: 2s
retries: 5
restart: unless-stopped
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
volumes:
pg_data:
redis_data:
minio_data: