forked from mtusi2026/mtusi2026lab3
[+] Completed lab 3
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
x-app: &app
|
||||
image: mtusi-messenger:lab3
|
||||
pull_policy: never
|
||||
environment: &app-env
|
||||
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}
|
||||
|
||||
x-api: &api
|
||||
<<: *app
|
||||
stop_grace_period: 10s
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
|
||||
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-a:
|
||||
<<: *api
|
||||
environment:
|
||||
<<: *app-env
|
||||
INSTANCE_ID: api-a
|
||||
|
||||
api-b:
|
||||
<<: *api
|
||||
environment:
|
||||
<<: *app-env
|
||||
INSTANCE_ID: api-b
|
||||
|
||||
lb:
|
||||
image: haproxy:3.0.11-alpine
|
||||
volumes:
|
||||
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
ports:
|
||||
- "127.0.0.1:${APP_BIND_PORT:-8080}:8080"
|
||||
depends_on:
|
||||
- api-a
|
||||
- api-b
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
Reference in New Issue
Block a user