version: "3"
services:

  orthanc-pg-a:
    image: ${ORTHANC_IMAGE_UNDER_TESTS:-orthancteam/orthanc:latest}
    container_name: orthanc-pg-a
    depends_on: [pg-a]
    restart: unless-stopped
    ports: ["8062:8042"]
    volumes: ["storage-orthanc-a:/var/lib/orthanc/db"]
    environment:
      VERBOSE_STARTUP: "true"
      VERBOSE_ENABLED: "true"
      TRANSFERS_PLUGIN_ENABLED: "true"
      # increase this timeout for large transfers (it is configured at 2sec by the default integration tests config)
      ORTHANC__HTTP_TIMEOUT: "60"
      ORTHANC__TRANSFERS__PEER_CONNECTIVITY_TIMEOUT: "10"
      # disable DICOMWEB to avoid the metadata cache to consume disk space after StableStudy -> difficult to compare disk sizes
      DICOM_WEB_PLUGIN_ENABLED: "false"
      ORTHANC__POSTGRESQL: |
        {
          "Host": "pg-a",
          "TransactionMode": "ReadCommitted"
        }
      ORTHANC__AUTHENTICATION_ENABLED: "false"
      ORTHANC__ORTHANC_PEERS: |
        {
          "a": {
            "Url": "http://orthanc-pg-a:8042/",
            "RemoteSelf": "b"
          },
          "b": {
            "Url": "http://orthanc-pg-b:8042/"
          }
        }
      ORTHANC__OVERWRITE_INSTANCES: "true"

  orthanc-pg-b:
    image: ${ORTHANC_IMAGE_UNDER_TESTS:-orthancteam/orthanc:latest}
    container_name: orthanc-pg-b
    depends_on: [pg-b]
    restart: unless-stopped
    ports: ["8063:8042"]
    volumes: ["storage-orthanc-b:/var/lib/orthanc/db"]
    environment:
      VERBOSE_STARTUP: "true"
      VERBOSE_ENABLED: "true"
      TRANSFERS_PLUGIN_ENABLED: "true"
      # increase this timeout for large transfers (it is configured at 2sec by the default integration tests config)
      ORTHANC__HTTP_TIMEOUT: "60"
      ORTHANC__TRANSFERS__PEER_CONNECTIVITY_TIMEOUT: "10"
      DICOM_WEB_PLUGIN_ENABLED: "false"
      ORTHANC__POSTGRESQL: |
        {
          "Host": "pg-b",
          "TransactionMode": "ReadCommitted"
        }
      ORTHANC__AUTHENTICATION_ENABLED: "false"
      ORTHANC__ORTHANC_PEERS: |
        {
          "a": {
            "Url": "http://orthanc-pg-a:8042/",
            "RemoteSelf": "b"
          },
          "b": {
            "Url": "http://orthanc-pg-b:8042/"
          }
        }
      ORTHANC__OVERWRITE_INSTANCES: "true"

  pg-a:
    image: postgres:15
    container_name: pg-a
    restart: unless-stopped
    volumes: 
      - "storage-pg-a:/var/lib/postgresql/data"
    environment:
      POSTGRES_HOST_AUTH_METHOD: "trust"

  pg-b:
    image: postgres:15
    container_name: pg-b
    restart: unless-stopped
    volumes: 
      - "storage-pg-b:/var/lib/postgresql/data"
    environment:
      POSTGRES_HOST_AUTH_METHOD: "trust"

volumes:
  storage-orthanc-a:
  storage-orthanc-b:
  storage-pg-a:
  storage-pg-b:
