149 lines
4.8 KiB
YAML
149 lines
4.8 KiB
YAML
services:
|
|
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-lab3:3.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-lab3:3.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
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}
|
|
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-lab3:3.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
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}
|
|
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-lab3:3.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
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}
|
|
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-lab3:3.0
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-messenger}:${POSTGRES_PASSWORD:-local-only-password}@postgres:5432/${POSTGRES_DB:-messenger}
|
|
REDIS_URL: redis://redis:6379/0
|
|
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}
|
|
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:
|