forked from mtusi2026/mtusi2026lab2
ЛР2: PostgreSQL, Bearer-сессии и Valkey — уровень 4
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
name: mtusi-lab2
|
||||
x-app: &app
|
||||
build: .
|
||||
image: mtusi-messenger:lab2
|
||||
environment: &env
|
||||
APP_HOST: 0.0.0.0
|
||||
APP_PORT: 8080
|
||||
APP_ENV: lab
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
SESSION_STORE: postgres
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
CACHE_URL_FILE: /run/secrets/cache_url
|
||||
secrets: [database_url, cache_url]
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16.6-bookworm
|
||||
environment:
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets: [postgres_password]
|
||||
volumes: [postgres-data:/var/lib/postgresql/data]
|
||||
healthcheck:
|
||||
test: [CMD-SHELL, 'pg_isready -U messenger -d messenger']
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
valkey:
|
||||
image: valkey/valkey:8.0.2-alpine
|
||||
command: [valkey-server, --appendonly, 'yes', --maxmemory, 64mb, --maxmemory-policy, allkeys-lru]
|
||||
volumes: [valkey-data:/data]
|
||||
healthcheck:
|
||||
test: [CMD, valkey-cli, ping]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
migrate:
|
||||
<<: *app
|
||||
command: [python, app/migrate.py]
|
||||
depends_on:
|
||||
postgres: {condition: service_healthy}
|
||||
api:
|
||||
<<: *app
|
||||
ports: ['127.0.0.1:${HOST_PORT:-8080}:8080']
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
valkey: {condition: service_healthy}
|
||||
expiry-api:
|
||||
<<: *app
|
||||
profiles: [test]
|
||||
environment:
|
||||
<<: *env
|
||||
SESSION_TTL_SECONDS: 2
|
||||
ports: ['127.0.0.1:8082:8080']
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
volumes:
|
||||
postgres-data:
|
||||
valkey-data:
|
||||
secrets:
|
||||
postgres_password:
|
||||
file: ./secrets/postgres_password
|
||||
database_url:
|
||||
file: ./secrets/database_url
|
||||
cache_url:
|
||||
file: ./secrets/cache_url
|
||||
Reference in New Issue
Block a user