forked from mtusi2026/mtusi2026lab2
77 lines
1.9 KiB
YAML
77 lines
1.9 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:16.4-alpine
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
|
volumes:
|
|
- postgres-data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 5s
|
|
ports:
|
|
- "127.0.0.1:5431:5432"
|
|
|
|
redis:
|
|
image: redis:7.4-alpine
|
|
command: ["redis-server", "--appendonly", "yes"]
|
|
volumes:
|
|
- redis-data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 5s
|
|
|
|
migrate:
|
|
image: migrate/migrate:v4.17.1
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./migrations:/migrations
|
|
command:
|
|
- "-path=/migrations"
|
|
- "-database=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable"
|
|
- "up"
|
|
restart: "no"
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
redis:
|
|
condition: service_healthy
|
|
environment:
|
|
PORT: ${PORT}
|
|
DATABASE_URL: ${DATABASE_URL}
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS}
|
|
MAX_MESSAGES: ${MAX_MESSAGES}
|
|
MAX_CONCURRENT_REQUESTS: ${MAX_CONCURRENT_REQUESTS}
|
|
DB_MAX_CONNS: ${DB_MAX_CONNS}
|
|
DB_MIN_CONNS: ${DB_MIN_CONNS}
|
|
DB_CONN_TIMEOUT_SECONDS: ${DB_CONN_TIMEOUT_SECONDS}
|
|
CACHE_URL: ${CACHE_URL}
|
|
CHAT_CACHE_TTL_SECONDS: 30
|
|
ports:
|
|
- "127.0.0.1:8080:8080"
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/health/ready"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 10s
|
|
|
|
volumes:
|
|
postgres-data:
|
|
redis-data: |