forked from mtusi2026/mtusi2026lab2
Подтверждённые сообщения и действующие сессии переживают перезапуск, история читается по индексу, копия восстанавливается в новый том.
112 lines
2.8 KiB
YAML
112 lines
2.8 KiB
YAML
# Local stand for lab2. Fixed container names so scripts/restart.sh can restart
|
|
# the API and both stores without guessing the compose project name.
|
|
# Volumes are named and are not removed by restart.
|
|
name: mtusi-lab2
|
|
|
|
x-api-image: &api-image mtusi-messenger:lab2
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16.8-bookworm
|
|
container_name: mtusi-lab2-postgres
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_DB: messenger
|
|
command:
|
|
- postgres
|
|
- -c
|
|
- synchronous_commit=on
|
|
- -c
|
|
- fsync=on
|
|
- -c
|
|
- full_page_writes=on
|
|
volumes:
|
|
- pg-data:/var/lib/postgresql/data
|
|
ports:
|
|
- "127.0.0.1:5432:5432"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7.4.2-alpine
|
|
container_name: mtusi-lab2-redis
|
|
environment:
|
|
REDIS_PASSWORD: ${REDIS_PASSWORD}
|
|
command:
|
|
- redis-server
|
|
- --appendonly
|
|
- "yes"
|
|
- --appendfsync
|
|
- always
|
|
- --dir
|
|
- /data
|
|
- --requirepass
|
|
- ${REDIS_PASSWORD}
|
|
volumes:
|
|
- redis-data:/data
|
|
ports:
|
|
- "127.0.0.1:6379:6379"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "redis-cli -a \"$$REDIS_PASSWORD\" --no-auth-warning ping | grep -q PONG"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
api:
|
|
image: *api-image
|
|
build: .
|
|
container_name: mtusi-lab2-api
|
|
environment: &api-env
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: "8080"
|
|
DATABASE_URL: postgresql://messenger:${POSTGRES_PASSWORD}@postgres:5432/messenger
|
|
REDIS_URL: redis://:${REDIS_PASSWORD}@redis:6379/0
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
MAX_MESSAGES: ${MAX_MESSAGES:-100000}
|
|
MAX_PER_SECOND: ${MAX_PER_SECOND:-10000}
|
|
MAX_INFLIGHT_BODIES: ${MAX_INFLIGHT_BODIES:-32}
|
|
ports:
|
|
- "127.0.0.1:8080:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import os,urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).read()"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 20s
|
|
stop_grace_period: 15s
|
|
restart: unless-stopped
|
|
|
|
api-short:
|
|
profiles: ["shortttl"]
|
|
image: *api-image
|
|
build: .
|
|
container_name: mtusi-lab2-api-short
|
|
environment:
|
|
<<: *api-env
|
|
SESSION_TTL_SECONDS: "2"
|
|
ports:
|
|
- "127.0.0.1:8081:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
restart: "no"
|
|
|
|
volumes:
|
|
pg-data:
|
|
redis-data:
|