services:
  omics-endpoint:
    image: samply/itcc-omics-ingest:main
    environment:
      API_KEY: ${GENERATE_API_KEY}
      BEAM_APP_ID_LONG: omics-endpoint.${PROXY_ID}
      BEAM_SECRET: ${FOCUS_BEAM_SECRET_SHORT}
      DWH_SOCKET_ID: ${DWH_SOCKET_ID}
      DWH_TASK_ID: ${DWH_TASK_ID}
      PARTNER_ID: ${SITE_ID}
      ML_API_KEY: ${GENERATE_API_KEY}
    labels:
      - "traefik.http.routers.omics.rule=Host(`${HOST}`) &&
        PathPrefix(`/api/upload`)"
      - "traefik.enable=true"
      - "traefik.http.services.omics.loadbalancer.server.port=6080"
      - "traefik.http.routers.omics.tls=true"
      - "traefik.http.middlewares.omics-stripprefix.stripprefix.prefixes=/api"
      - "traefik.http.routers.omics.middlewares=omics-stripprefix"

  patientlist-db:
    image: postgres:${POSTGRES_TAG}
    container_name: bridgehead-patientlist-db
    restart: unless-stopped
    environment:
      POSTGRES_DB: mainzelliste
      POSTGRES_USER: ${ML_DB_USER}
      POSTGRES_PASSWORD: ${PATIENTLIST_POSTGRES_PASSWORD}
    volumes:
      - "patientlist-db-data:/var/lib/postgresql/data"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${ML_DB_USER} -d mainzelliste"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  patientlist:
    image: medicalinformatics/mainzelliste:latest
    container_name: bridgehead-patientlist
    restart: unless-stopped
    depends_on:
      patientlist-db:
        condition: service_healthy
    environment:
      ML_API_KEY: ${GENERATE_API_KEY}
      ML_DB_HOST: patientlist-db
      ML_DB_PORT: "5432"
      ML_DB_NAME: mainzelliste
      ML_DB_USER: ${ML_DB_USER}
      ML_DB_PASS: ${PATIENTLIST_POSTGRES_PASSWORD}
      ML_DB_DRIVER: org.postgresql.Driver
      ML_DB_TYPE: postgresql
      ML_LOG_LEVEL: INFO
      ML_ALLOWEDREMOTEADDRESSES: "127.0.0.1,::1,172.16.0.0/12"

    secrets:
      - mainzelliste.docker.conf
      - source: symmetric_key
        target: /etc/resources/keys/symmetric_key.json

volumes:
  patientlist-db-data:
secrets:
  mainzelliste.docker.conf:
    file: /etc/bridgehead/mainzelliste/mainzelliste.docker.conf

  symmetric_key:
    file: /var/bridgehead/mainzelliste/keyset_siv.json
