services:

  # pgbouncer:
  #   image: edoburu/pgbouncer:latest
  #   environment:
  #     - DB_USER=postgres
  #     - DB_PASSWORD=hbZkzny5xrvVH
  #     - DB_HOST=db
  #     # - DB_NAME=test
  #     - AUTH_TYPE=scram-sha-256 # remove/comment this line if using postgres:13 and lower
  #     - POOL_MODE=transaction
  #     - ADMIN_USERS=postgres,dbuser
  #   ports:
  #     - "5432:5432"
  #   depends_on:
  #     - db
  #   healthcheck:
  #     test: ['CMD', 'pg_isready', '-h', 'localhost']

  sftp:
    image: git.financial-service-plus.de/fsp-ops/rclone-sftp-proxy:main
    environment:
      SSH_PORT: 2022
    ports:
      - "2022:2022"
    volumes:
      - "./abag-prod/sftp/users.json:/app/config/users.json:ro"
      - "./abag-prod/sftp/root:/data:rw"

  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - $HOME/.docker/config.json:/config.json:ro
    command: --interval 120
    # environment:
      # WATCHTOWER_NOTIFICATIONS: msteams
      # WATCHTOWER_NOTIFICATIONS_LEVEL: info
      # WATCHTOWER_NOTIFICATION_MSTEAMS_USE_LOG_DATA: true
      # WATCHTOWER_NOTIFICATION_MSTEAMS_HOOK_URL: https://financialserviceplusgmbh.webhook.office.com/webhookb2/0639b4d3-9d27-45b4-9a65-9738abedf553@d2d7eff3-a55c-4a72-919f-0b9e5efa8bb0/IncomingWebhook/b7d872a39f324856aa83d2a7f4dd1624/8d4ccc82-bc45-4727-8d0d-948ee01b4032/V2n2xEh2j0HFRymD7Sk9s0qcrUGbaGiqmwEyr0T7BIwsI1

  web:
    image: git.financial-service-plus.de/fspdigital/zr-portal-web:develop
    ports:
      - "80:80"
    environment:
      - GRAPHQL_URL=http://10.0.0.6:3000/graphql
    restart: unless-stopped

  worker:
    image: git.financial-service-plus.de/fspdigital/zr-portal-worker:develop
    environment:
      - DEFAULT_IMPORT_BELEGE_FROM=undefined
      - TZ=Europe/Berlin
      - DATABASE_HOST=db-2:5432
      - DATABASE_NAME=zr
      - DATABASE_OWNER=zr
      - DATABASE_OWNER_PASSWORD=ss93c2evuxqb
      - ABAG_DATABASE_HOST=10.248.178.27:5432
      - ABAG_DATABASE_NAME=ab_webzr_int?ssl=true
      - PGSSLMODE=no-verify
      - NODE_TLS_REJECT_UNAUTHORIZED=0
      - ABAG_DATABASE_OWNER=ab_webzr_int_flatex_read
      - ABAG_DATABASE_OWNER_PASSWORD=TdC55OzwkBJMHzwfvZAY8dzNRr2bzgQeU0LhTlsVOOV6CRCW2k6PZdW81tHzZXNn
      - ABAG_SFTP_HOST=sftp
      - ABAG_SFTP_PORT=2022
      - ABAG_SFTP_USER=abag-prod
      - ABAG_SFTP_PRIVATE_KEY_FILE=/keys/id_ed25519
      - ABAG_SFTP_PDF_DIRECTORY=/abag_files/pdf
      - ABAG_SFTP_XML_DIRECTORY=/abag_files/xml
      - PATH_ARCHIVE=/archive
      - PATH_DATENLESER_IN=/datenleser_input
      - PATH_DATENLESER_OUTPUT=/datenleser_output
      - PATH_ARCHIVE_UNKNOWN_OUTPUT=/archive/unknown/datenleser
      - PATH_ARCHIVE_UNKNOWN_SFTP_OUTPUT=/archive/unknown/sftp
      - PDF_REGEX='.*\.pdf$'
      - XML_REGEX='.*\.xml$'
    volumes:
      - "./abag-prod/sftp_keys:/keys:ro"
      - "./abag-prod/datareader/in:/datenleser_input:rw"
      - "./abag-prod/datareader/out:/datenleser_output:rw"
      - "./abag-prod/archive:/archive:rw"
    restart: unless-stopped

  server:
    image: git.financial-service-plus.de/fspdigital/zr-portal-server:develop
    ports:
      - "3000:3000"
    environment:
      - TZ=Europe/Berlin
      - JWT_SECRET=96zx2zkdgqyvb45f
      - CORS_ALLOWED_ORIGINS=http://localhost:40711,http://10.0.0.6:80
      - DATABASE_HOST=db-2:5432
      - DATABASE_NAME=zr
      - DATABASE_OWNER=zr
      - DATABASE_OWNER_PASSWORD=ss93c2evuxqb
      - DATABASE_AUTHENTICATOR=zr_authenticator
      - DATABASE_AUTHENTICATOR_PASSWORD=umhbdp6ku3iv
      - DATABASE_ANONYMOUS_ROLE=zr_anonymous
      - DATABASE_ADMIN_ROLE=zr_admin
      - DATABASE_MANAGER_ROLE=zr_manager
      - DATABASE_USER_ROLE=zr_user
    volumes:
      - "./abag-prod/sftp_keys:/keys:ro"
      - "./abag-prod/datareader/in:/datenleser_input:rw"
      - "./abag-prod/datareader/out:/datenleser_output:rw"
      - "./abag-prod/archive:/archive:rw"
    restart: unless-stopped
