version: "3.6"
services:
  database:
    image: mdillon/postgis:10
    volumes:
      - db-data:/var/lib/postgresql/data
    env_file:
      - env/dem.env
      - env/dem_db.env
    environment:
      INSTANCE_ID: "prism-view-server_database"
    deploy:
      placement:
        constraints: [node.role == manager]
    networks:
      - intnet
  redis:
    image: redis
    volumes:
      - redis-data:/data
    deploy:
      placement:
        constraints: [node.role == manager]
    networks:
      - intnet
  renderer:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_core:latest
    volumes:
      - type: tmpfs
        target: /tmp
      - type: volume
        source: cache-db
        target: /cache-db
      - type: volume
        source: instance-data
        target: /var/www/pvs
    env_file:
      - env/dem.env
      - env/dem_db.env
      - env/dem_django.env
      - env/dem_obs.env
    environment:
      INSTANCE_ID: "prism-data-access-server_renderer"
      INSTALL_DIR: "/var/www/pdas/dev/"
      INIT_SCRIPTS: "/configure.sh /init-db.sh"
    configs:
      - source: init-db
        target: /init-db.sh
    deploy:
      replicas: 1
    networks:
      - intnet
    command:
      ["/wait-for-database.sh", "/run-httpd.sh"]
  cache:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_cache:latest
    volumes:
      - type: tmpfs
        target: /tmp
      - type: volume
        source: cache-db
        target: /cache-db
    env_file:
      - env/dem.env
      - env/dem_db.env
      - env/dem_obs.env
    environment:
      INSTANCE_ID: "prism-view-server_cache"
      RENDERER_HOST: renderer
    deploy:
      replicas: 1
    networks:
      - intnet
    command:
      ["/run-httpd.sh"]
  seeder:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_cache:latest
    volumes:
      - type: tmpfs
        target: /tmp
      - type: volume
        source: cache-db
        target: /cache-db
    env_file:
      - env/dem.env
      - env/dem_obs.env
      - env/dem_redis.env
    environment:
      INSTANCE_ID: "prism-data-access-server_seeder"
      RENDERER_HOST: renderer
    deploy:
      replicas: 0
    networks:
      - intnet
    command:
      ["/run-seeder.sh"]
  preprocessor:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_preprocessor:latest
    env_file:
      - env/dem.env
      - env/dem_obs.env
      - env/dem_redis.env
      - env/dem_preprocessor.env
    environment:
      INSTANCE_ID: "prism-view-server_preprocessor"
    deploy:
      replicas: 1
    networks:
      - intnet
    command:
      ["/run-preprocessor.sh"]
  registrar:
    image: registry.gitlab.eox.at/esa/prism/vs/pvs_core:latest
    volumes:
      - type: tmpfs
        target: /tmp
      - type: volume
        source: instance-data
        target: /var/www/pdas
    env_file:
      - env/dem.env
      - env/dem_db.env
      - env/dem_obs.env
      - env/dem_redis.env
    environment:
      INSTANCE_ID: "prism-view-server_registrar"
      INSTALL_DIR: "/var/www/pdas/dev/"
      SCALEFACTOR: "1"
      IN_MEMORY: "false"
      INIT_SCRIPTS: "/configure.sh /init-db.sh"
    configs:
      - source: init-db
        target: /init-db.sh
    deploy:
      replicas: 1
    networks:
      - intnet
    command:
      ["/wait-for-database.sh", "/run-registrar.sh"]
  client:
    image: registry.gitlab.eox.at/esa/prism/vhr_image_2018/pdas_client:latest
    deploy:
      replicas: 1
configs:
  init-db:
    file: ./config/dem_init-db.sh
  mapcache-dev:
    file: ./config/dem_mapcache-dev.xml
  mapcache-ops:
    file: ./config/dem_mapcache-ops.xml
  client-dev:
    file: ./config/dem_index-dev.html
  client-ops:
    file: ./config/dem_index-ops.html
volumes:
  db-data:
  redis-data:
  cache-db:
  instance-data:
networks:
  intnet:
