Bring the application, own tests, Dockerfile, toolchain, compose stack, migrations, secret generator, restart hook, evidence scripts and CI job from the lab 2 solution commit 8cddb09 unchanged, merge the lab 2 Makefile targets into the lab 3 skeleton Makefile without touching its targets, and append the lab 2 solution variables to the skeleton .env.example. The package version follows the contract version 1.3.0. This is the starting point of the lab 3 cycle: lint, own tests and the offline skeleton check pass before any lab 3 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
124 lines
3.2 KiB
YAML
124 lines
3.2 KiB
YAML
x-app: &app
|
|
image: mtusi-messenger:lab2
|
|
build: .
|
|
environment: &app-environment
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
CACHE_URL_FILE: /run/secrets/cache_url
|
|
CURSOR_SECRET_FILE: /run/secrets/cursor_secret
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-4}
|
|
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
|
secrets: [database_url, cache_url, cursor_secret]
|
|
networks: [backend]
|
|
|
|
x-ready: &ready
|
|
test: ["CMD", "python", "-c", "import urllib.request,sys;sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8080/health/ready',timeout=2).status==200 else 1)"]
|
|
interval: 3s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 15s
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:17.11-alpine@sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b
|
|
user: "70:70"
|
|
environment:
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
secrets: [postgres_password]
|
|
volumes: [pgdata:/var/lib/postgresql/data]
|
|
shm_size: 256m
|
|
healthcheck:
|
|
test: ["CMD", "pg_isready", "-h", "127.0.0.1", "-U", "messenger", "-d", "messenger"]
|
|
interval: 2s
|
|
timeout: 3s
|
|
retries: 30
|
|
start_period: 10s
|
|
stop_grace_period: 10s
|
|
restart: unless-stopped
|
|
networks: [backend]
|
|
|
|
valkey:
|
|
image: valkey/valkey:8.1.11-alpine@sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a
|
|
user: "999:1000"
|
|
command:
|
|
- valkey-server
|
|
- /run/secrets/valkey.conf
|
|
- --appendonly
|
|
- "yes"
|
|
- --appendfsync
|
|
- always
|
|
- --maxmemory
|
|
- 64mb
|
|
- --maxmemory-policy
|
|
- volatile-lru
|
|
secrets: [valkey.conf]
|
|
volumes: [valkeydata:/data]
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "REDISCLI_AUTH=\"$$(sed -n 's/^requirepass //p' /run/secrets/valkey.conf)\" valkey-cli ping | grep -q PONG"]
|
|
interval: 2s
|
|
timeout: 3s
|
|
retries: 30
|
|
stop_grace_period: 10s
|
|
restart: unless-stopped
|
|
networks: [backend]
|
|
|
|
migrate:
|
|
<<: *app
|
|
command: ["python", "-m", "messenger.migrate"]
|
|
healthcheck:
|
|
disable: true
|
|
restart: "no"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
|
|
api:
|
|
<<: *app
|
|
ports: ["127.0.0.1:${API_PORT:-8080}:8080"]
|
|
healthcheck: *ready
|
|
stop_grace_period: 10s
|
|
restart: unless-stopped
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
valkey:
|
|
condition: service_started
|
|
|
|
api-shortttl:
|
|
<<: *app
|
|
profiles: [faults]
|
|
environment:
|
|
<<: *app-environment
|
|
SESSION_TTL_SECONDS: "2"
|
|
WEB_CONCURRENCY: "1"
|
|
ports: ["127.0.0.1:${SHORTTTL_PORT:-8082}:8080"]
|
|
healthcheck: *ready
|
|
stop_grace_period: 10s
|
|
restart: unless-stopped
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
valkey:
|
|
condition: service_started
|
|
|
|
secrets:
|
|
postgres_password:
|
|
file: ./secrets/postgres_password
|
|
database_url:
|
|
file: ./secrets/database_url
|
|
valkey.conf:
|
|
file: ./secrets/valkey.conf
|
|
cache_url:
|
|
file: ./secrets/cache_url
|
|
cursor_secret:
|
|
file: ./secrets/cursor_secret
|
|
|
|
volumes:
|
|
pgdata:
|
|
valkeydata:
|
|
|
|
networks:
|
|
backend:
|