forked from mtusi2026/mtusi2026lab2
FastAPI + asyncpg + Redis/argon2id. Пользователи/чаты/участники/сообщения в Postgres с версионируемой миграцией и keyset-пагинацией. Basic-вход, Bearer-сессии в Redis с TTL и AOF-персистентностью. make check/test/ test-persistence/validate зелёные; evidence по EXPLAIN ANALYZE, короткому TTL и падению Redis приложены в REPORT.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
69 lines
1.6 KiB
YAML
69 lines
1.6 KiB
YAML
name: mtusi2026lab2
|
|
|
|
services:
|
|
api:
|
|
build: .
|
|
image: mtusi2026lab2-api:local
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: 8080
|
|
APP_ENV: lab
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
CACHE_URL_FILE: /run/secrets/cache_url
|
|
secrets:
|
|
- database_url
|
|
- cache_url
|
|
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/live', timeout=2)"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 10s
|
|
|
|
postgres:
|
|
image: postgres:16.4
|
|
environment:
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
secrets:
|
|
- postgres_password
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
|
|
redis:
|
|
image: redis:7.4.1
|
|
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"]
|
|
volumes:
|
|
- redisdata:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
|
|
volumes:
|
|
pgdata:
|
|
redisdata:
|
|
|
|
secrets:
|
|
database_url:
|
|
file: ./secrets/database_url.txt
|
|
cache_url:
|
|
file: ./secrets/cache_url.txt
|
|
postgres_password:
|
|
file: ./secrets/postgres_password.txt
|