forked from mtusi2026/mtusi2026lab2
50 lines
1.2 KiB
YAML
50 lines
1.2 KiB
YAML
x-app: &app
|
|
image: mtusi-messenger:lab2
|
|
pull_policy: never
|
|
environment:
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: 8080
|
|
APP_ENV: ${APP_ENV:-lab}
|
|
LOG_LEVEL: ${LOG_LEVEL:-info}
|
|
DB_HOST: postgres
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run scripts/init-env.sh first}
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15.18-bookworm
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run scripts/init-env.sh first}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 20
|
|
|
|
migrate:
|
|
<<: *app
|
|
build: .
|
|
command: ["node", "dist/migrate.js"]
|
|
healthcheck:
|
|
disable: true
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
|
|
api:
|
|
<<: *app
|
|
ports:
|
|
- "127.0.0.1:${APP_BIND_PORT:-8080}:8080"
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
|
|
volumes:
|
|
postgres_data:
|