forked from mtusi2026/mtusi2026lab4
211 lines
7.5 KiB
YAML
211 lines
7.5 KiB
YAML
services:
|
|
minio:
|
|
image: cgr.dev/chainguard/minio@sha256:0dab2f9fee1c1139ae8753b5e35bb4461af2a276cfe0923a2504c75a6170bc64
|
|
command: server /data --console-address ':9001'
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadminpassword}
|
|
volumes:
|
|
- s3_data:/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "test -f /data/.minio.sys/format.json"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
|
|
minio-init:
|
|
build:
|
|
context: ./infra
|
|
dockerfile: minio-init.Dockerfile
|
|
image: mtusi-minio-init:1.0
|
|
depends_on:
|
|
minio: {condition: service_healthy}
|
|
environment:
|
|
MINIO_ENDPOINT: http://minio:9000
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadminpassword}
|
|
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
|
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
|
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-messenger-api-secret-123}
|
|
|
|
postgres:
|
|
image: postgres:16.4-alpine
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-local-only-password}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-messenger} -d ${POSTGRES_DB:-messenger}"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
mem_limit: 512m
|
|
cpus: 1.0
|
|
|
|
redis:
|
|
image: redis:7.4.2-alpine
|
|
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"]
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
mem_limit: 256m
|
|
cpus: 0.5
|
|
|
|
migrate:
|
|
build: .
|
|
image: mtusi-messenger-lab4:4.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
command: ["python", "scripts/migrate.py"]
|
|
depends_on:
|
|
postgres: {condition: service_healthy}
|
|
|
|
api-1:
|
|
build: .
|
|
image: mtusi-messenger-lab4:4.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
S3_ENDPOINT: http://minio:9000
|
|
S3_REGION: us-east-1
|
|
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
|
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
|
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-messenger-api-secret-123}
|
|
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
|
|
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
INSTANCE_ID: api-1
|
|
ENABLE_DEBUG_METRICS: ${ENABLE_DEBUG_METRICS:-1}
|
|
expose: ["8080"]
|
|
depends_on:
|
|
migrate: {condition: service_completed_successfully}
|
|
minio-init: {condition: service_completed_successfully}
|
|
postgres: {condition: service_healthy}
|
|
redis: {condition: service_healthy}
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
mem_limit: 256m
|
|
cpus: 0.5
|
|
|
|
api-2:
|
|
build: .
|
|
image: mtusi-messenger-lab4:4.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
S3_ENDPOINT: http://minio:9000
|
|
S3_REGION: us-east-1
|
|
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
|
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
|
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-messenger-api-secret-123}
|
|
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
|
|
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
INSTANCE_ID: api-2
|
|
ENABLE_DEBUG_METRICS: ${ENABLE_DEBUG_METRICS:-1}
|
|
expose: ["8080"]
|
|
depends_on:
|
|
migrate: {condition: service_completed_successfully}
|
|
minio-init: {condition: service_completed_successfully}
|
|
postgres: {condition: service_healthy}
|
|
redis: {condition: service_healthy}
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
mem_limit: 256m
|
|
cpus: 0.5
|
|
|
|
api-3:
|
|
build: .
|
|
image: mtusi-messenger-lab4:4.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
S3_ENDPOINT: http://minio:9000
|
|
S3_REGION: us-east-1
|
|
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
|
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
|
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-messenger-api-secret-123}
|
|
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
|
|
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
INSTANCE_ID: api-3
|
|
ENABLE_DEBUG_METRICS: ${ENABLE_DEBUG_METRICS:-1}
|
|
expose: ["8080"]
|
|
depends_on:
|
|
migrate: {condition: service_completed_successfully}
|
|
minio-init: {condition: service_completed_successfully}
|
|
postgres: {condition: service_healthy}
|
|
redis: {condition: service_healthy}
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
mem_limit: 256m
|
|
cpus: 0.5
|
|
|
|
api-4:
|
|
build: .
|
|
image: mtusi-messenger-lab4:4.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
S3_ENDPOINT: http://minio:9000
|
|
S3_REGION: us-east-1
|
|
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
|
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
|
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-messenger-api-secret-123}
|
|
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
|
|
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
INSTANCE_ID: api-4
|
|
ENABLE_DEBUG_METRICS: ${ENABLE_DEBUG_METRICS:-1}
|
|
expose: ["8080"]
|
|
depends_on:
|
|
migrate: {condition: service_completed_successfully}
|
|
minio-init: {condition: service_completed_successfully}
|
|
postgres: {condition: service_healthy}
|
|
redis: {condition: service_healthy}
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
mem_limit: 256m
|
|
cpus: 0.5
|
|
|
|
lb:
|
|
image: nginx:1.27.2-alpine
|
|
ports: ["8080:8080"]
|
|
volumes:
|
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
depends_on:
|
|
api-1: {condition: service_healthy}
|
|
api-2: {condition: service_healthy}
|
|
api-3: {condition: service_healthy}
|
|
api-4: {condition: service_healthy}
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:8080/health/live >/dev/null"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
mem_limit: 128m
|
|
cpus: 0.25
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
s3_data:
|