Files
mtusi2026lab3/compose.yaml
T

66 lines
1.7 KiB
YAML

services:
postgres:
image: postgres:16.6-alpine
environment:
POSTGRES_DB: messenger
POSTGRES_USER: messenger
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger_local_only}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
interval: 3s
timeout: 3s
retries: 20
api1:
build: .
environment: &api-env
APP_HOST: 0.0.0.0
APP_PORT: 8080
INSTANCE_ID: api1
DATABASE_URL: jdbc:postgresql://postgres:5432/messenger
DATABASE_USER: messenger
DATABASE_PASSWORD: ${POSTGRES_PASSWORD:-messenger_local_only}
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
expose: ["8080"]
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "java", "-cp", "/app/messenger.jar", "ru.mtusi.lab3.ReadyProbe"]
interval: 2s
timeout: 2s
retries: 20
api2:
build: .
environment:
<<: *api-env
INSTANCE_ID: api2
expose: ["8080"]
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "java", "-cp", "/app/messenger.jar", "ru.mtusi.lab3.ReadyProbe"]
interval: 2s
timeout: 2s
retries: 20
lb:
image: nginx:1.27.3-alpine
ports:
- "127.0.0.1:${HOST_PORT:-8080}:8080"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
api1:
condition: service_healthy
api2:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:8080/health/ready"]
interval: 2s
timeout: 2s
retries: 20
volumes:
postgres_data: