Completed for a grade of four
This commit is contained in:
+35
-4
@@ -4,7 +4,6 @@ services:
|
||||
|
||||
postgres:
|
||||
image: postgres:17.6-alpine3.22
|
||||
# pg_stat_statements counts executed queries, track 1 uses it to measure the cache stampede.
|
||||
command: ["postgres", "-c", "shared_preload_libraries=pg_stat_statements", "-c", "pg_stat_statements.track=all"]
|
||||
environment:
|
||||
POSTGRES_DB: messenger
|
||||
@@ -20,6 +19,11 @@ services:
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: 1g
|
||||
restart: unless-stopped
|
||||
|
||||
redis:
|
||||
@@ -44,6 +48,11 @@ services:
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 128m
|
||||
restart: unless-stopped
|
||||
|
||||
# One-shot: applies Flyway migrations once and exits. Replicas start only after it succeeded,
|
||||
@@ -53,7 +62,7 @@ services:
|
||||
image: mtusi-messenger:lab3
|
||||
command: ["migrate"]
|
||||
healthcheck:
|
||||
disable: true
|
||||
test: ["NONE"]
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
@@ -65,6 +74,11 @@ services:
|
||||
DB_PASSWORD_FILE: /run/secrets/db_password
|
||||
secrets:
|
||||
- db_password
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 384m
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
@@ -73,6 +87,10 @@ services:
|
||||
# Interchangeable replicas: no container_name and no published port, traffic only through `lb`.
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: 512m
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
@@ -95,11 +113,13 @@ services:
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
SESSION_CACHE_SINGLE_FLIGHT: ${SESSION_CACHE_SINGLE_FLIGHT:-true}
|
||||
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
|
||||
SHUTDOWN_DRAIN_DELAY_MS: "3000"
|
||||
secrets:
|
||||
- db_password
|
||||
- redis_password
|
||||
# SIGTERM: Ktor stops accepting, finishes requests in flight (shutdownGracePeriod 3 s, shutdownTimeout 10 s).
|
||||
stop_grace_period: 15s
|
||||
# SIGTERM: readiness 503 and 3 s drain (HAProxy needs <= 2 s to notice), then Ktor closes the socket and
|
||||
# finishes requests in flight within 5 s. 3 + 5 = 8 s < 10 s before Docker sends SIGKILL.
|
||||
stop_grace_period: 10s
|
||||
restart: unless-stopped
|
||||
|
||||
lb:
|
||||
@@ -111,6 +131,17 @@ services:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
# Port 8404 (health and stats) stays inside the compose network.
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8404/healthz"]
|
||||
interval: 5s
|
||||
timeout: 2s
|
||||
retries: 3
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 128m
|
||||
restart: unless-stopped
|
||||
|
||||
secrets:
|
||||
|
||||
Reference in New Issue
Block a user