forked from mtusi2026/mtusi2026lab2
feat: lab2 done
This commit is contained in:
+66
-12
@@ -1,13 +1,67 @@
|
||||
services:
|
||||
nest-app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger:lab2
|
||||
ports:
|
||||
- ${APP_PUBLIC_PORT:-8080}:${APP_PORT:-8080}
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
BENCHMARK_CURSOR_SEARCH: ${BENCHMARK_CURSOR_SEARCH:-binary}
|
||||
stop_grace_period: 30s
|
||||
postgres:
|
||||
image: postgres:16.4-alpine
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
|
||||
redis:
|
||||
image: redis:7.4.2-alpine
|
||||
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec"]
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
|
||||
migrate:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger:lab2
|
||||
command: ["node", "dist/database/migration.runner.js"]
|
||||
env_file: [.env]
|
||||
depends_on:
|
||||
postgres: { condition: service_healthy }
|
||||
redis: { condition: service_healthy }
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger:lab2
|
||||
ports:
|
||||
- "${APP_PUBLIC_PORT:-8080}:${APP_PORT:-8080}"
|
||||
env_file: [.env]
|
||||
# Declared here so a one-off experiment can override them from the shell
|
||||
# (shell env wins over env_file), e.g.:
|
||||
# CACHE_MODE=naive CACHE_MISS_DELAY_MS=75 docker compose up -d api
|
||||
# SESSION_TTL_SECONDS=2 docker compose up -d api
|
||||
environment:
|
||||
CACHE_MODE: ${CACHE_MODE:-protected}
|
||||
CACHE_MISS_DELAY_MS: ${CACHE_MISS_DELAY_MS:-0}
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
depends_on:
|
||||
migrate: { condition: service_completed_successfully }
|
||||
postgres: { condition: service_healthy }
|
||||
redis: { condition: service_healthy }
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:'+ (process.env.APP_PORT||8080) + '/health/ready').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
redis-data:
|
||||
|
||||
Reference in New Issue
Block a user