Files
mtusi2026lab4/compose.yaml
T

120 lines
3.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Локальный стенд lab4: LB (nginx) → API × 2 → PostgreSQL + Redis + MinIO.
# Секреты читаются из ./secrets/*.txt (не коммитятся).
services:
postgres:
image: postgres:16.4-alpine
environment:
POSTGRES_USER: messenger
POSTGRES_PASSWORD: messenger
POSTGRES_DB: messenger
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
interval: 3s
timeout: 3s
retries: 20
redis:
image: redis:7.4-alpine
command: ["redis-server", "--save", "", "--appendonly", "no"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 3s
timeout: 3s
retries: 20
s3:
image: minio/minio:latest
command: ["server", "/data", "--console-address", ":9001"]
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin-local-only}
volumes:
- s3data:/data
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 3s
timeout: 3s
retries: 30
minio-init:
image: python:3.12-slim
depends_on:
s3:
condition: service_healthy
environment:
S3_ENDPOINT: http://s3:9000
S3_REGION: us-east-1
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minioadmin}
S3_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-minioadmin-local-only}
volumes:
- ./scripts/bootstrap_s3.py:/bootstrap_s3.py:ro
command: ["sh", "-c", "pip install --quiet boto3==1.35.76 && python /bootstrap_s3.py"]
restart: "no"
api-1:
build: .
environment:
DATABASE_URL: postgresql+psycopg://messenger:messenger@postgres:5432/messenger
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
INSTANCE_ID: api-1
S3_ENDPOINT: http://s3:9000
S3_REGION: us-east-1
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minioadmin}
S3_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-minioadmin-local-only}
MAX_UPLOAD_BYTES: "10485760"
MAX_IMAGE_PIXELS: "40000000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
s3:
condition: service_healthy
minio-init:
condition: service_completed_successfully
command: ["sh", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8080"]
api-2:
build: .
environment:
DATABASE_URL: postgresql+psycopg://messenger:messenger@postgres:5432/messenger
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
INSTANCE_ID: api-2
S3_ENDPOINT: http://s3:9000
S3_REGION: us-east-1
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minioadmin}
S3_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-minioadmin-local-only}
MAX_UPLOAD_BYTES: "10485760"
MAX_IMAGE_PIXELS: "40000000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
s3:
condition: service_healthy
minio-init:
condition: service_completed_successfully
command: ["sh", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8080"]
lb:
image: nginx:1.27-alpine
ports:
- "8080:8080"
volumes:
- ./infra/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api-1
- api-2
volumes:
pgdata:
s3data: