84 lines
1.9 KiB
YAML
84 lines
1.9 KiB
YAML
name: mtusi2026lab2
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16.4-bookworm
|
|
environment:
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7.2.5-bookworm
|
|
command:
|
|
- redis-server
|
|
- --appendonly
|
|
- "yes"
|
|
- --appendfsync
|
|
- everysec
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
migrate:
|
|
build:
|
|
context: .
|
|
image: mtusi-messenger:lab2
|
|
command: ["python", "-m", "app.migrate"]
|
|
environment:
|
|
PGHOST: postgres
|
|
PGPORT: "5432"
|
|
PGDATABASE: messenger
|
|
PGUSER: messenger
|
|
PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
disable: true
|
|
restart: "no"
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
image: mtusi-messenger:lab2
|
|
environment:
|
|
PGHOST: postgres
|
|
PGPORT: "5432"
|
|
PGDATABASE: messenger
|
|
PGUSER: messenger
|
|
PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: "6379"
|
|
USER_CACHE_TTL_SECONDS: "${USER_CACHE_TTL_SECONDS:-60}"
|
|
SESSION_TTL_SECONDS: "${SESSION_TTL_SECONDS:-3600}"
|
|
ports:
|
|
- "127.0.0.1:18081:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
restart: unless-stopped
|
|
stop_grace_period: 10s
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data: |