forked from mtusi2026/mtusi2026lab2
91 lines
2.4 KiB
YAML
91 lines
2.4 KiB
YAML
services:
|
|
backend:
|
|
build:
|
|
context: .
|
|
target: runtime
|
|
restart: unless-stopped
|
|
init: true
|
|
environment:
|
|
NODE_ENV: production
|
|
APP_ENV: ${APP_ENV:-lab}
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: 8080
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-local_dev_password}@postgres:5432/${POSTGRES_DB:-chat}
|
|
CACHE_URL: redis://redis:6379/0
|
|
CACHE_PREFIX: ${CACHE_PREFIX:-messenger:cache:v1}
|
|
SESSION_STORE: ${SESSION_STORE:-postgres}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
APP_DATA_DIR: /app/data
|
|
ports:
|
|
- '127.0.0.1:${APP_PORT:-8080}:8080'
|
|
volumes:
|
|
- backend_data:/app/data
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_started
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- node
|
|
- -e
|
|
- "fetch('http://127.0.0.1:8080/health/ready').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"
|
|
interval: 10s
|
|
timeout: 3s
|
|
start_period: 20s
|
|
retries: 5
|
|
stop_grace_period: 30s
|
|
|
|
migrate:
|
|
build:
|
|
context: .
|
|
target: migrate
|
|
environment:
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-local_dev_password}@postgres:5432/${POSTGRES_DB:-chat}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
|
|
postgres:
|
|
image: postgres:17.6-bookworm
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:-chat}
|
|
POSTGRES_USER: ${POSTGRES_USER:-app}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-local_dev_password}
|
|
ports:
|
|
- '127.0.0.1:${POSTGRES_PORT:-5432}:5432'
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ['CMD-SHELL', 'pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"']
|
|
interval: 5s
|
|
timeout: 3s
|
|
start_period: 10s
|
|
retries: 10
|
|
stop_grace_period: 30s
|
|
|
|
redis:
|
|
image: redis:7.4.5-alpine
|
|
restart: unless-stopped
|
|
command:
|
|
['redis-server', '--appendonly', 'yes', '--appendfsync', 'everysec']
|
|
ports:
|
|
- '127.0.0.1:${REDIS_PORT:-6379}:6379'
|
|
volumes:
|
|
- redis_data:/data
|
|
healthcheck:
|
|
test: ['CMD', 'redis-cli', 'ping']
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
stop_grace_period: 30s
|
|
|
|
volumes:
|
|
postgres_data:
|
|
redis_data:
|
|
backend_data:
|