Implement lab3 scaling, shared idempotency, failure research and defense guide
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
name: mtusi-lab3-kraykin
|
||||
x-api: &api
|
||||
image: mtusi-messenger:lab3
|
||||
build: .
|
||||
environment: &api-env
|
||||
APP_PORT: 8080
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
CACHE_URL_FILE: /run/secrets/cache_url
|
||||
CURSOR_KEY_FILE: /run/secrets/cursor_key
|
||||
POOL_DIAGNOSTICS: ${POOL_DIAGNOSTICS:-0}
|
||||
DB_POOL_MAX: ${DB_POOL_MAX:-10}
|
||||
secrets: [database_url, cache_url, cursor_key]
|
||||
cpus: ${API_CPUS:-1}
|
||||
mem_limit: ${API_MEMORY:-256m}
|
||||
stop_grace_period: 8s
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17.6-alpine
|
||||
environment:
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets: [postgres_password]
|
||||
volumes: [postgres_data:/var/lib/postgresql/data]
|
||||
cpus: 2
|
||||
mem_limit: 512m
|
||||
shm_size: 128m
|
||||
healthcheck:
|
||||
test: [CMD-SHELL, 'pg_isready -U messenger -d messenger']
|
||||
interval: 1s
|
||||
timeout: 2s
|
||||
retries: 30
|
||||
valkey:
|
||||
image: valkey/valkey:8.1.3-alpine
|
||||
command: [valkey-server, /run/secrets/valkey_config]
|
||||
secrets: [valkey_config]
|
||||
cpus: 0.5
|
||||
mem_limit: 128m
|
||||
migrate:
|
||||
<<: *api
|
||||
command: [migrate]
|
||||
depends_on:
|
||||
postgres: {condition: service_healthy}
|
||||
restart: 'no'
|
||||
api:
|
||||
<<: *api
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
valkey: {condition: service_started}
|
||||
tests:
|
||||
image: mtusi-messenger-tests:lab3
|
||||
cpus: 2
|
||||
mem_limit: 1024m
|
||||
profiles: [verify]
|
||||
build:
|
||||
context: .
|
||||
target: tests
|
||||
environment:
|
||||
DATABASE_TEST_URL_FILE: /run/secrets/database_url
|
||||
secrets: [database_url]
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
lb:
|
||||
image: haproxy:3.2.6-alpine
|
||||
volumes: ['./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro']
|
||||
ports: ['127.0.0.1:${APP_PORT:-8083}:8080']
|
||||
cpus: 1
|
||||
mem_limit: 128m
|
||||
depends_on:
|
||||
api: {condition: service_healthy}
|
||||
healthcheck:
|
||||
test: [CMD-SHELL, 'wget -q -O /dev/null http://127.0.0.1:8080/health/ready']
|
||||
interval: 2s
|
||||
timeout: 4s
|
||||
retries: 20
|
||||
secrets:
|
||||
postgres_password: {file: ./secrets/postgres_password}
|
||||
database_url: {file: ./secrets/database_url}
|
||||
valkey_config: {file: ./secrets/valkey_config}
|
||||
cache_url: {file: ./secrets/cache_url}
|
||||
cursor_key: {file: ./secrets/cursor_key}
|
||||
volumes:
|
||||
postgres_data:
|
||||
Reference in New Issue
Block a user