68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
name: mtusi-lab2
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16.4-alpine
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:?Set POSTGRES_USER in .env}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
|
POSTGRES_DB: ${POSTGRES_DB:?Set POSTGRES_DB in .env}
|
|
ports:
|
|
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 30
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7.4.2-alpine
|
|
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "always", "--save", ""]
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 30
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
environment:
|
|
APP_HOST: ${APP_HOST:-0.0.0.0}
|
|
APP_PORT: 8080
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
|
|
DB_POOL_MIN_SIZE: ${DB_POOL_MIN_SIZE:-1}
|
|
DB_POOL_MAX_SIZE: ${DB_POOL_MAX_SIZE:-10}
|
|
DB_POOL_ACQUIRE_TIMEOUT_SECONDS: ${DB_POOL_ACQUIRE_TIMEOUT_SECONDS:-3}
|
|
DB_COMMAND_TIMEOUT_SECONDS: ${DB_COMMAND_TIMEOUT_SECONDS:-5}
|
|
REDIS_URL: redis://redis:6379/0
|
|
REDIS_TIMEOUT_SECONDS: ${REDIS_TIMEOUT_SECONDS:-2}
|
|
ports:
|
|
- "127.0.0.1:${APP_PORT:-8080}:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2)"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 12
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|