services:
  brapi-java-server-v2:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
      - "5005:5005"
    depends_on:
      - brapi-db
    volumes:
      - .\src\main\resources\properties\application.properties:/home/brapi/properties/application.properties
  keycloak-brapi:
    image: quay.io/keycloak/keycloak:latest
    entrypoint: /opt/keycloak/bin/kc.sh start-dev
    depends_on:
      - keycloak-db
    environment:
      - KEYCLOAK_USER=admin
      - KEYCLOAK_PASSWORD=admin
      # The KC_HOSTNAME needs to be the same as the defined keycloak-brapi service in the compose file for a local setup.
      # This allows the brapi app to talk to the keycloak container via the service name in the url, and sets up keycloak
      # url defaults so that when brapi gets auth urls from keycloak it can still talk to it.
      - KC_HOSTNAME=keycloak-brapi
      - KC_DB=postgres
      - KC_DB_URL=jdbc:postgresql://keycloak-db:5432/keycloak
      - KC_DB_SCHEMA=public
      - KC_DB_USERNAME=keycloak
      - KC_DB_PASSWORD=password
      - KC_HOSTNAME_STRICT=false
      - KC_HOSTNAME_STRICT_HTTPS=false
      - KC_HTTP_PORT=8008

      - KC_LOG_LEVEL=info
      - KC_METRICS_ENABLED=true
      - KC_HEALTH_ENABLED=true
      - KEYCLOAK_ADMIN=admin
      - KEYCLOAK_ADMIN_PASSWORD=admin
    ports:
      - "8008:8008"
  brapi-db:
    image: postgres:17.2
    environment:
      POSTGRES_USER: brapi
      POSTGRES_PASSWORD: password
    volumes:
      - brapi-data:/var/lib/postgresql/data
    ports:
      - "5433:5432"
  keycloak-db:
    image: postgres:17.2
    volumes:
      - keycloak-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: keycloak
      POSTGRES_PASSWORD: password
    ports:
      - "5434:5432"
volumes:
  keycloak-data:
  brapi-data:
