59 lines
1.7 KiB
YAML
59 lines
1.7 KiB
YAML
name: messenger-lab2
|
|
|
|
services:
|
|
api:
|
|
build: .
|
|
image: messenger-lab2-api
|
|
env_file: .env
|
|
environment:
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
secrets: [database_url, cache_url]
|
|
ports: ["127.0.0.1:8080:8080"]
|
|
depends_on:
|
|
postgres: {condition: service_healthy}
|
|
redis: {condition: service_healthy}
|
|
restart: unless-stopped
|
|
stop_grace_period: 10s
|
|
|
|
postgres:
|
|
image: postgres:17.11-alpine
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
command: ["postgres", "-c", "fsync=on", "-c", "synchronous_commit=on"]
|
|
secrets: [postgres_password]
|
|
volumes: ["pgdata:/var/lib/postgresql/data"]
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U messenger -d messenger"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 12
|
|
start_period: 10s
|
|
restart: unless-stopped
|
|
stop_grace_period: 30s
|
|
|
|
redis:
|
|
image: redis:7.4.11-alpine
|
|
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
|
|
volumes:
|
|
- ./infra/redis.conf:/usr/local/etc/redis/redis.conf:ro
|
|
- redisdata:/data
|
|
secrets: [redis_auth]
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "REDISCLI_AUTH=\"$$(sed -n 's/^requirepass //p' /run/secrets/redis_auth)\" redis-cli ping | grep -q PONG"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 12
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata: {}
|
|
redisdata: {}
|
|
|
|
secrets:
|
|
postgres_password: {file: ./secrets/postgres_password}
|
|
database_url: {file: ./secrets/database_url}
|
|
cache_url: {file: ./secrets/cache_url}
|
|
redis_auth: {file: ./secrets/redis_auth}
|