forked from mtusi2026/mtusi2026lab5
156 lines
3.9 KiB
YAML
156 lines
3.9 KiB
YAML
name: mtusi-lab5
|
|
|
|
x-app: &app
|
|
image: mtusi-lab5-app:local
|
|
build:
|
|
context: .
|
|
env_file:
|
|
- .env
|
|
init: true
|
|
restart: unless-stopped
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
minio:
|
|
condition: service_healthy
|
|
minio-init:
|
|
condition: service_completed_successfully
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16.8-alpine
|
|
container_name: mtusi-lab5-postgres
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
|
|
interval: 2s
|
|
timeout: 3s
|
|
retries: 30
|
|
restart: unless-stopped
|
|
|
|
minio:
|
|
image: pgsty/silo:RELEASE.2026-10-26T00-00-00Z
|
|
container_name: mtusi-lab5-minio
|
|
command: ["server", "/data", "--console-address", ":9001"]
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
|
volumes:
|
|
- miniodata:/data
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://127.0.0.1:9000/minio/health/live"]
|
|
interval: 2s
|
|
timeout: 3s
|
|
retries: 30
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
minio-init:
|
|
image: pgsty/silo:RELEASE.2026-10-26T00-00-00Z
|
|
container_name: mtusi-lab5-minio-init
|
|
depends_on:
|
|
minio:
|
|
condition: service_healthy
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
|
|
S3_BUCKET: ${S3_BUCKET}
|
|
entrypoint: ["/bin/sh", "-c"]
|
|
command:
|
|
- |
|
|
set -eu
|
|
mc alias set local http://minio:9000 "$$MINIO_ROOT_USER" "$$MINIO_ROOT_PASSWORD"
|
|
mc mb -p "local/$$S3_BUCKET" || true
|
|
mc anonymous set none "local/$$S3_BUCKET"
|
|
restart: "no"
|
|
|
|
rabbitmq:
|
|
image: rabbitmq:3.13.7-management-alpine
|
|
container_name: mtusi-lab5-rabbitmq
|
|
environment:
|
|
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
|
|
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
|
|
volumes:
|
|
- rabbitdata:/var/lib/rabbitmq
|
|
- ./infra/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
|
|
healthcheck:
|
|
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
|
|
interval: 5s
|
|
timeout: 10s
|
|
retries: 20
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
api-1:
|
|
<<: *app
|
|
container_name: mtusi-lab5-api-1
|
|
environment:
|
|
INSTANCE_ID: api-1
|
|
labels:
|
|
lab.role: api
|
|
lab.instance_id: api-1
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"]
|
|
interval: 3s
|
|
timeout: 5s
|
|
retries: 30
|
|
start_period: 20s
|
|
|
|
api-2:
|
|
<<: *app
|
|
container_name: mtusi-lab5-api-2
|
|
environment:
|
|
INSTANCE_ID: api-2
|
|
labels:
|
|
lab.role: api
|
|
lab.instance_id: api-2
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"]
|
|
interval: 3s
|
|
timeout: 5s
|
|
retries: 30
|
|
start_period: 20s
|
|
|
|
worker:
|
|
<<: *app
|
|
container_name: mtusi-lab5-worker
|
|
command: ["python", "-m", "app.worker"]
|
|
environment:
|
|
INSTANCE_ID: worker-1
|
|
MALLOC_ARENA_MAX: "2"
|
|
mem_limit: 512m
|
|
restart: on-failure
|
|
labels:
|
|
lab.role: worker
|
|
|
|
nginx:
|
|
image: nginx:1.27.5-alpine
|
|
container_name: mtusi-lab5-nginx
|
|
depends_on:
|
|
api-1:
|
|
condition: service_healthy
|
|
api-2:
|
|
condition: service_healthy
|
|
ports:
|
|
- "8080:8080"
|
|
volumes:
|
|
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/live"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 20
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|
|
miniodata:
|
|
rabbitdata:
|