forked from mtusi2026/mtusi2026lab2
68 lines
1.8 KiB
YAML
68 lines
1.8 KiB
YAML
# Local stand. Secrets come from .env, which is not committed.
|
|
# PostgreSQL is the source of truth. Redis caches session lookups and has no volume.
|
|
services:
|
|
postgres:
|
|
image: postgres:16.10-alpine
|
|
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: 5s
|
|
retries: 30
|
|
ports:
|
|
- "127.0.0.1:5432:5432"
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7.4.11-alpine
|
|
command: ["redis-server", "--save", "", "--appendonly", "no"]
|
|
ports:
|
|
- "127.0.0.1:6379:6379"
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 2s
|
|
timeout: 3s
|
|
retries: 30
|
|
restart: unless-stopped
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
environment:
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: "8080"
|
|
APP_ENV: ${APP_ENV:-lab}
|
|
LOG_LEVEL: ${LOG_LEVEL:-info}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
SHUTDOWN_TIMEOUT_SECONDS: ${SHUTDOWN_TIMEOUT_SECONDS:-5}
|
|
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
|
|
REDIS_URL: redis://redis:6379/0
|
|
HISTORY_CACHE: ${HISTORY_CACHE:-protected}
|
|
ports:
|
|
- "127.0.0.1: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=3)
|
|
interval: 3s
|
|
timeout: 5s
|
|
retries: 30
|
|
start_period: 20s
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|