version: "3.6"
services:
  database:
    volumes:
      - type: tmpfs
        target: /dev/shm
        tmpfs:
          size: 536870912
  renderer:
    environment:
      INSTALL_DIR: "/var/www/pvs/ops/"
    deploy:
      labels:
        # router for basic auth based access (https)
        - "traefik.http.routers.vhr18-renderer.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/ows`, `/opensearch`, `/admin`)"
        - "traefik.http.routers.vhr18-renderer.middlewares=auth@file,compress@file"
        - "traefik.http.routers.vhr18-renderer.tls=true"
        - "traefik.http.routers.vhr18-renderer.tls.certresolver=default"
        - "traefik.http.routers.vhr18-renderer.entrypoints=https"
        # router for basic auth based access (http)
        - "traefik.http.routers.vhr18-renderer-redirect.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/ows`, `/opensearch`, `/admin`)"
        - "traefik.http.routers.vhr18-renderer-redirect.middlewares=redirect@file"
        - "traefik.http.routers.vhr18-renderer-redirect.entrypoints=http"
        # router for referrer based access (https)
        - "traefik.http.routers.vhr18-renderer_referer.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/ows`, `/opensearch`, `/admin`) && HeadersRegexp(`Referer`, `(https?://)?(panda.copernicus.eu|panda.cdsv3.eu|panda-demo.ondaprism.eu|vhr18.pvs.prism.eox.at)/?`)"
        - "traefik.http.routers.vhr18-renderer_referer.middlewares=compress@file"
        - "traefik.http.routers.vhr18-renderer_referer.tls=true"
        - "traefik.http.routers.vhr18-renderer_referer.tls.certresolver=default"
        - "traefik.http.routers.vhr18-renderer_referer.entrypoints=https"
        # router for referrer based access (http)
        - "traefik.http.routers.vhr18-renderer_referer-redirect.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/ows`, `/opensearch`, `/admin`) && HeadersRegexp(`Referer`, `(https?://)?(panda.copernicus.eu|panda.cdsv3.eu|panda-demo.ondaprism.eu|vhr18.pvs.prism.eox.at)/?`)"
        - "traefik.http.routers.vhr18-renderer_referer-redirect.middlewares=redirect@file"
        - "traefik.http.routers.vhr18-renderer_referer-redirect.entrypoints=http"
        # general
        - "traefik.http.services.vhr18-renderer.loadbalancer.sticky=false"
        - "traefik.http.services.vhr18-renderer.loadbalancer.server.port=80"
        - "traefik.docker.network=pvs_extnet"
        - "traefik.docker.lbswarm=true"
        - "traefik.enable=true"
      resources:
        limits:
          memory: 12G  #TODO 4G ended up with many processes in D state, supposedly because of swapping
    networks:
      - extnet
  cache:
    configs:
      - source: mapcache-ops
        target: /mapcache-template.xml
    deploy:
      labels:
        - "traefik.http.middlewares.cache-stripprefix.stripprefix.prefixes=/cache"
        # router for basic auth based access (https)
        - "traefik.http.routers.vhr18-cache.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/cache`)"
        - "traefik.http.routers.vhr18-cache.middlewares=auth@file,cache-stripprefix,compress@file"
        - "traefik.http.routers.vhr18-cache.tls=true"
        - "traefik.http.routers.vhr18-cache.tls.certresolver=default"
        - "traefik.http.routers.vhr18-cache.entrypoints=https"
        # router for basic auth based access (http)
        - "traefik.http.routers.vhr18-cache-redirect.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/cache`)"
        - "traefik.http.routers.vhr18-cache-redirect.middlewares=redirect@file"
        - "traefik.http.routers.vhr18-cache-redirect.entrypoints=http"
        # router for referrer based access (https)
        - "traefik.http.routers.vhr18-cache_referer.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/cache`) && HeadersRegexp(`Referer`, `(https?://)?(panda.copernicus.eu|panda.cdsv3.eu|panda-demo.ondaprism.eu|vhr18.pvs.prism.eox.at)/?`)"
        - "traefik.http.routers.vhr18-cache_referer.middlewares=cache-stripprefix,compress@file"
        - "traefik.http.routers.vhr18-cache_referer.tls=true"
        - "traefik.http.routers.vhr18-cache_referer.tls.certresolver=default"
        - "traefik.http.routers.vhr18-cache_referer.entrypoints=https"
        # router for referrer based access (http)
        - "traefik.http.routers.vhr18-cache_referer-redirect.rule=Host(`vhr18.pvs.prism.eox.at`, `a.vhr18.pvs.prism.eox.at`, `b.vhr18.pvs.prism.eox.at`, `c.vhr18.pvs.prism.eox.at`, `d.vhr18.pvs.prism.eox.at`, `e.vhr18.pvs.prism.eox.at`, `f.vhr18.pvs.prism.eox.at`, `g.vhr18.pvs.prism.eox.at`, `h.vhr18.pvs.prism.eox.at`) && PathPrefix(`/cache`) && HeadersRegexp(`Referer`, `(https?://)?(panda.copernicus.eu|panda.cdsv3.eu|panda-demo.ondaprism.eu|vhr18.pvs.prism.eox.at)/?`)"
        - "traefik.http.routers.vhr18-cache_referer-redirect.middlewares=redirect@file"
        - "traefik.http.routers.vhr18-cache_referer-redirect.entrypoints=http"
        # general
        - "traefik.http.services.vhr18-cache.loadbalancer.sticky=false"
        - "traefik.http.services.vhr18-cache.loadbalancer.server.port=80"
        - "traefik.docker.network=pvs_extnet"
        - "traefik.docker.lbswarm=true"
        - "traefik.enable=true"
    networks:
      - extnet
  registrar:
    environment:
      INSTALL_DIR: "/var/www/pvs/ops/"
  # redis-manager:
  #   environment:
  #     INSTALL_DIR: "/var/www/pvs/ops/"
  client:
    configs:
      - source: client-ops
        target: /usr/share/nginx/html/index.html
    deploy:
      labels:
        # router for basic auth based access (https)
        - "traefik.http.routers.vhr18-client.rule=Host(`vhr18.pvs.prism.eox.at`)"
        - "traefik.http.routers.vhr18-client.middlewares=auth@file,compress@file"
        - "traefik.http.routers.vhr18-client.tls=true"
        - "traefik.http.routers.vhr18-client.tls.certresolver=default"
        - "traefik.http.routers.vhr18-client.entrypoints=https"
        # router for basic auth based access (http)
        - "traefik.http.routers.vhr18-client-redirect.rule=Host(`vhr18.pvs.prism.eox.at`)"
        - "traefik.http.routers.vhr18-client-redirect.middlewares=redirect@file"
        - "traefik.http.routers.vhr18-client-redirect.entrypoints=http"
        # general
        - "traefik.http.services.vhr18-client.loadbalancer.sticky=false"
        - "traefik.http.services.vhr18-client.loadbalancer.server.port=80"
        - "traefik.docker.network=pvs_extnet"
        - "traefik.docker.lbswarm=true"
        - "traefik.enable=true"
    networks:
      - extnet
  preprocessor:
    volumes:
      - type: bind
        source: /var/vhr
        target: /tmp
networks:
  extnet:
    name: vhr18-extnet
    external: true
