version: '3.8'

services:
  postgres:
    image: ehrbase/ehrbase-v2-postgres:16.2
    environment:
      POSTGRES_DB: ehrbase
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      EHRBASE_USER: ehrbase
      EHRBASE_PASSWORD: ehrbase
    ports:
      - "5433:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres || exit 0"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 30s
    volumes:
      - postgres_data:/var/lib/postgresql/data

  ehrbase:
    image: ehrbase/ehrbase:2.26.0
    environment:
      DB_URL: jdbc:postgresql://postgres:5432/ehrbase
      DB_USER: ehrbase
      DB_PASS: ehrbase
      DB_USER_ADMIN: ehrbase
      DB_PASS_ADMIN: ehrbase
      SECURITY_AUTHTYPE: BASIC
      SECURITY_AUTHUSER: ehrbase-user
      SECURITY_AUTHPASSWORD: SuperSecretPassword
      SECURITY_AUTHADMINUSER: ehrbase-admin
      SECURITY_AUTHADMINPASSWORD: EvenMoreSecretPassword
    ports:
      - "8080:8080"
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/ehrbase/rest/status"]
      interval: 10s
      timeout: 5s
      retries: 15

volumes:
  postgres_data:
