105 lines
2.7 KiB
YAML
105 lines
2.7 KiB
YAML
name: mtusi-messenger-lab2
|
|
|
|
x-app: &app
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
image: mtusi-messenger:lab2
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:18-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873
|
|
environment:
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
|
|
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
|
ports:
|
|
- "127.0.0.1:${POSTGRES_PORT:-5432}:5432"
|
|
volumes:
|
|
- postgres18-data:/var/lib/postgresql
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
redis:
|
|
image: redis:7.4-alpine
|
|
command:
|
|
- redis-server
|
|
- --appendonly
|
|
- "yes"
|
|
- --appendfsync
|
|
- everysec
|
|
- --save
|
|
- "60"
|
|
- "1"
|
|
ports:
|
|
- "127.0.0.1:${REDIS_PORT:-6379}:6379"
|
|
volumes:
|
|
- redis7-data:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 3s
|
|
restart: unless-stopped
|
|
migrate:
|
|
<<: *app
|
|
entrypoint: ["/usr/local/bin/migrate"]
|
|
command: ["up"]
|
|
environment:
|
|
APP_CONFIG: /etc/messenger/dev/config.yaml
|
|
POSTGRES_HOST: postgres
|
|
POSTGRES_PORT: "5432"
|
|
POSTGRES_DATABASE: ${POSTGRES_DB:-messenger}
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
|
|
POSTGRES_SSL_MODE: disable
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
restart: "no"
|
|
|
|
api:
|
|
<<: *app
|
|
env_file:
|
|
- path: .env
|
|
required: false
|
|
environment:
|
|
APP_CONFIG: /etc/messenger/dev/config.yaml
|
|
POSTGRES_HOST: postgres
|
|
POSTGRES_PORT: "5432"
|
|
POSTGRES_DATABASE: ${POSTGRES_DB:-messenger}
|
|
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
|
|
POSTGRES_SSL_MODE: disable
|
|
REDIS_ENABLED: "${REDIS_ENABLED:-true}"
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: "6379"
|
|
CACHE_ENABLED: "${CACHE_ENABLED:-true}"
|
|
ports:
|
|
- "127.0.0.1:${SERVER_PORT:-8080}:8080"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/ready"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 5
|
|
start_period: 5s
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
postgres18-data:
|
|
name: mtusi-messenger-lab2-postgres18-data
|
|
redis7-data:
|
|
name: mtusi-messenger-lab2-redis7-data
|