Files
mtusi2026lab3-fork/compose.yaml
T

92 lines
1.9 KiB
YAML

name: mtusi-messenger-lab2
services:
postgres:
image: postgres:16.4-alpine
restart: unless-stopped
environment:
POSTGRES_USER: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
POSTGRES_DB: messenger
secrets:
- postgres_password
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
networks:
- internal
redis:
image: redis:7.4-alpine
restart: unless-stopped
command:
- redis-server
- --appendonly
- "yes"
- --appendfsync
- everysec
- --save
- "60 1000"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
start_period: 5s
networks:
- internal
api:
build:
context: .
dockerfile: Dockerfile
image: mtusi-messenger-api:lab2
restart: unless-stopped
ports:
- "8080:8080"
environment:
APP_HOST: "0.0.0.0"
APP_PORT: "8080"
DATABASE_URL_FILE: /run/secrets/database_url
CACHE_URL_FILE: /run/secrets/cache_url
SESSION_STORE: "redis"
SESSION_TTL_SECONDS: "3600"
secrets:
- database_url
- cache_url
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1"]
interval: 10s
timeout: 3s
retries: 5
start_period: 15s
networks:
- internal
secrets:
postgres_password:
file: ./secrets/postgres_password
database_url:
file: ./secrets/database_url
cache_url:
file: ./secrets/cache_url
volumes:
postgres_data:
redis_data:
networks:
internal:
driver: bridge