version: "3.6"
x-vs-version: :release-1.1.0 # bumpversion
services:
  database:
    volumes:
      - type: tmpfs
        target: /dev/shm
        tmpfs:
          size: 536870912
  renderer:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_core:release-1.1.0 # bumpversion
    environment:
      INSTALL_DIR: "/var/www/pvs/ops/"
      INSTANCE_DIR: "/var/www/pvs/ops/pvs_instance/"
    deploy:
      labels:
        # router for basic auth access (https)
        - "traefik.http.routers.dem-renderer.rule=Host(`dem.pass.copernicus.eu`, `a.dem.pass.copernicus.eu`, `b.dem.pass.copernicus.eu`, `c.dem.pass.copernicus.eu`, `d.dem.pass.copernicus.eu`, `e.dem.pass.copernicus.eu`, `f.dem.pass.copernicus.eu`, `g.dem.pass.copernicus.eu`, `h.dem.pass.copernicus.eu`, `dem.pdas.prism.eox.at`, `a.dem.pdas.prism.eox.at`, `b.dem.pdas.prism.eox.at`, `c.dem.pdas.prism.eox.at`, `d.dem.pdas.prism.eox.at`, `e.dem.pdas.prism.eox.at`, `f.dem.pdas.prism.eox.at`, `g.dem.pdas.prism.eox.at`, `h.dem.pdas.prism.eox.at`) && PathPrefix(`/ows`, `/opensearch`, `/admin`)"
        - "traefik.http.routers.dem-renderer.middlewares=auth@file,compress@file,cors@file"
        - "traefik.http.routers.dem-renderer.tls=true"
        - "traefik.http.routers.dem-renderer.tls.certresolver=default"
        - "traefik.http.routers.dem-renderer.entrypoints=https"
        # router for basic auth based access (http)
        - "traefik.http.routers.dem-renderer-redirect.rule=Host(`dem.pass.copernicus.eu`, `a.dem.pass.copernicus.eu`, `b.dem.pass.copernicus.eu`, `c.dem.pass.copernicus.eu`, `d.dem.pass.copernicus.eu`, `e.dem.pass.copernicus.eu`, `f.dem.pass.copernicus.eu`, `g.dem.pass.copernicus.eu`, `h.dem.pass.copernicus.eu`, `dem.pdas.prism.eox.at`, `a.dem.pdas.prism.eox.at`, `b.dem.pdas.prism.eox.at`, `c.dem.pdas.prism.eox.at`, `d.dem.pdas.prism.eox.at`, `e.dem.pdas.prism.eox.at`, `f.dem.pdas.prism.eox.at`, `g.dem.pdas.prism.eox.at`, `h.dem.pdas.prism.eox.at`) && PathPrefix(`/ows`, `/opensearch`, `/admin`)"
        - "traefik.http.routers.dem-renderer-redirect.middlewares=redirect@file"
        - "traefik.http.routers.dem-renderer-redirect.entrypoints=http"
        # general
        - "traefik.http.services.dem-renderer.loadbalancer.sticky=false"
        - "traefik.http.services.dem-renderer.loadbalancer.server.port=80"
        - "traefik.docker.network=dem-extnet"
        - "traefik.docker.lbswarm=true"
        - "traefik.enable=true"
      replicas: 3
      resources:
        limits:
          memory: 8G
      placement:
        constraints:
          - node.labels.type == external
    networks:
      - extnet
  cache:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_cache:release-1.1.0 # bumpversion
    configs:
      - source: mapcache-ops
        target: /mapcache-template.xml
    deploy:
      labels:
        - "traefik.http.middlewares.cache-stripprefix.stripprefix.prefixes=/cache"
        # router for basic auth access (https)
        - "traefik.http.routers.dem-cache.rule=Host(`dem.pass.copernicus.eu`, `a.dem.pass.copernicus.eu`, `b.dem.pass.copernicus.eu`, `c.dem.pass.copernicus.eu`, `d.dem.pass.copernicus.eu`, `e.dem.pass.copernicus.eu`, `f.dem.pass.copernicus.eu`, `g.dem.pass.copernicus.eu`, `h.dem.pass.copernicus.eu`, `dem.pdas.prism.eox.at`, `a.dem.pdas.prism.eox.at`, `b.dem.pdas.prism.eox.at`, `c.dem.pdas.prism.eox.at`, `d.dem.pdas.prism.eox.at`, `e.dem.pdas.prism.eox.at`, `f.dem.pdas.prism.eox.at`, `g.dem.pdas.prism.eox.at`, `h.dem.pdas.prism.eox.at`) && PathPrefix(`/cache`)"
        - "traefik.http.routers.dem-cache.middlewares=cache-stripprefix,auth@file,compress@file,cors@file"
        - "traefik.http.routers.dem-cache.tls=true"
        - "traefik.http.routers.dem-cache.tls.certresolver=default"
        - "traefik.http.routers.dem-cache.entrypoints=https"
        # router for basic auth based access (http)
        - "traefik.http.routers.dem-cache-redirect.rule=Host(`dem.pass.copernicus.eu`, `a.dem.pass.copernicus.eu`, `b.dem.pass.copernicus.eu`, `c.dem.pass.copernicus.eu`, `d.dem.pass.copernicus.eu`, `e.dem.pass.copernicus.eu`, `f.dem.pass.copernicus.eu`, `g.dem.pass.copernicus.eu`, `h.dem.pass.copernicus.eu`, `dem.pdas.prism.eox.at`, `a.dem.pdas.prism.eox.at`, `b.dem.pdas.prism.eox.at`, `c.dem.pdas.prism.eox.at`, `d.dem.pdas.prism.eox.at`, `e.dem.pdas.prism.eox.at`, `f.dem.pdas.prism.eox.at`, `g.dem.pdas.prism.eox.at`, `h.dem.pdas.prism.eox.at`) && PathPrefix(`/cache`)"
        - "traefik.http.routers.dem-cache-redirect.middlewares=redirect@file"
        - "traefik.http.routers.dem-cache-redirect.entrypoints=http"
        # general
        - "traefik.http.services.dem-cache.loadbalancer.sticky=false"
        - "traefik.http.services.dem-cache.loadbalancer.server.port=80"
        - "traefik.docker.network=dem-extnet"
        - "traefik.docker.lbswarm=true"
        - "traefik.enable=true"
      replicas: 3
      resources:
        limits:
          memory: 8G
      placement:
        constraints:
          - node.labels.type == external
    networks:
      - extnet
  registrar:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_core:release-1.1.0 # bumpversion
    environment:
      INSTALL_DIR: "/var/www/pvs/ops/"
      INSTANCE_DIR: "/var/www/pvs/ops/pvs_instance/"
    deploy:
      replicas: 0
      placement:
        constraints:
          - node.labels.type == internal
  ingestor:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_ingestor:release-1.1.0 # bumpversion
    environment:
      REDIS_PREPROCESS_MD_QUEUE_KEY: "preprocess_queue"
    deploy:
      placement:
        constraints: [node.role == manager]
  sftp:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_sftp:release-1.1.0 # bumpversion
    deploy:
      placement:
        constraints: [node.role == manager]
  client:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_client:release-1.1.0 # bumpversion
    configs:
      - source: client-ops
        target: /usr/share/nginx/html/index.html
    deploy:
      labels:
        # router for basic auth access (https)
        - "traefik.http.routers.dem-client.rule=Host(`dem.pdas.prism.eox.at`, `dem.pass.copernicus.eu`)"
        - "traefik.http.routers.dem-client.middlewares=auth@file,compress@file"
        - "traefik.http.routers.dem-client.tls=true"
        - "traefik.http.routers.dem-client.tls.certresolver=default"
        - "traefik.http.routers.dem-client.entrypoints=https"
        # router for basic auth access (http)
        - "traefik.http.routers.dem-client-redirect.rule=Host(`dem.pdas.prism.eox.at`, `dem.pass.copernicus.eu`)"
        - "traefik.http.routers.dem-client-redirect.middlewares=redirect@file"
        - "traefik.http.routers.dem-client-redirect.entrypoints=http"
        # general
        - "traefik.http.services.dem-client.loadbalancer.sticky=false"
        - "traefik.http.services.dem-client.loadbalancer.server.port=80"
        - "traefik.docker.network=dem-extnet"
        - "traefik.docker.lbswarm=true"
        - "traefik.enable=true"
      placement:
        constraints:
          - node.labels.type == external
    networks:
      - extnet
  preprocessor:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_preprocessor:release-1.1.0 # bumpversion
    volumes:
      - type: bind
        source: /var/vhr
        target: /tmp
    deploy:
      replicas: 0
      placement:
        constraints:
          - node.labels.type == internal
networks:
  extnet:
    name: dem-extnet
    external: true
