Files
mtusi2026lab2/docker-compose.yml

45 lines
1.2 KiB
YAML

services:
db:
image: postgres:16-alpine
container_name: mtusi-lab2-db
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-messenger}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
ports:
- "127.0.0.1:15432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-messenger}"]
interval: 5s
timeout: 3s
retries: 5
api:
build:
context: .
dockerfile: Dockerfile
container_name: mtusi-lab2-api
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
PORT: ${PORT:-8080}
DATABASE_URL: jdbc:postgresql://db:5432/${POSTGRES_DB:-messenger}
DATABASE_USER: ${POSTGRES_USER:-postgres}
DATABASE_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
ports:
- "127.0.0.1:8080:8080"
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health/ready"]
interval: 10s
timeout: 3s
start_period: 30s
retries: 5
volumes:
pgdata: