networks:
  test.local:

services:
  lb:
    image: 'traefik:latest'
    command:
        - "--api=true"
        - "--api.dashboard=true"
        - "--api.insecure=true"
        - "--providers.docker=true"
        - "--log.level=DEBUG"
        - "--accesslog"
        - "--entrypoints.web.address=:80"
        - "--entrypoints.web.http.encodedCharacters.allowEncodedSlash=true"
        - "--providers.docker.exposedbydefault=false"
    depends_on:
        - thruk1
        - thruk2
        - thruk3
    ports:
        - "127.0.0.3:60080:80"
    volumes:
        - /var/run/docker.sock:/var/run/docker.sock
    labels:
        - "traefik.enable=true"
        - "traefik.http.routers.dashboard.entrypoints=web"
        - "traefik.http.routers.dashboard.rule=(PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
        - "traefik.http.routers.dashboard.service=api@internal"
    networks:
      - test.local

  omd:
    build: omd/
    environment:
        - TZ=Europe/Berlin
    volumes:
        - ../../../:/thruk:ro
        - .:/scenario:ro
        - .:/test:ro
        - ../../../var/tmp:/var/tmp:rw
        - shared_var:/mnt/var
        - shared_etc:/mnt/etc
    networks:
      test.local:
        aliases:
          - omd.test.local
    hostname: omd
    domainname: test.local
    healthcheck:
      test: ["CMD", "curl", "-kf", "http://localhost/demo/"]
      interval: 10s
      timeout: 10s
      retries: 3
      start_period: 5m

  thruk1:
    build: thruk/
    depends_on:
        - omd
    ports:
        - "80"
    environment:
        - TZ=Europe/Berlin
    labels:
        - "traefik.enable=true"
        - "traefik.http.routers.thruk.entrypoints=web"
        - "traefik.http.routers.thruk.service=thruk"
        - "traefik.http.routers.thruk.rule=PathPrefix(`/demo`)"
        - "traefik.http.services.thruk.loadbalancer.server.port=80"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.port=80"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.path=/demo/thruk/cgi-bin/remote.cgi?lb_ping"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.interval=3s"
    volumes:
        - ../../../:/thruk:ro
        - ../../../var/tmp:/var/tmp:rw
        - ../cluster_fixed_e2e:/test:ro
        - ../cluster_fixed_e2e/t:/test/t:ro
        - shared_var:/mnt/var
        - shared_etc:/mnt/etc
    networks:
      test.local:
        aliases:
          - thruk1.test.local
    hostname: thruk1
    domainname: test.local
    healthcheck:
      test: ["CMD", "curl", "-kf", "http://localhost/demo/"]
      interval: 10s
      timeout: 10s
      retries: 3
      start_period: 5m

  thruk2:
    build: thruk/
    depends_on:
        - omd
    ports:
        - "80"
    environment:
        - TZ=Europe/Berlin
    labels:
        - "traefik.enable=true"
        - "traefik.http.routers.thruk.entrypoints=web"
        - "traefik.http.routers.thruk.service=thruk"
        - "traefik.http.routers.thruk.rule=PathPrefix(`/demo`)"
        - "traefik.http.services.thruk.loadbalancer.server.port=80"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.port=80"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.path=/demo/thruk/cgi-bin/remote.cgi?lb_ping"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.interval=3s"
    volumes:
        - ../../../:/thruk:ro
        - .:/scenario:ro
        - ../../../var/tmp:/var/tmp:rw
        - ../cluster_fixed_e2e:/test:ro
        - ../cluster_fixed_e2e/t:/test/t:ro
        - shared_var:/mnt/var
        - shared_etc:/mnt/etc
    networks:
      test.local:
        aliases:
          - thruk2.test.local
    hostname: thruk2
    domainname: test.local
    healthcheck:
      test: ["CMD", "curl", "-kf", "http://localhost/demo/"]
      interval: 10s
      timeout: 10s
      retries: 3
      start_period: 5m

  thruk3:
    build: thruk/
    depends_on:
        - omd
    ports:
        - "80"
    environment:
        - TZ=Europe/Berlin
    labels:
        - "traefik.enable=true"
        - "traefik.http.routers.thruk.entrypoints=web"
        - "traefik.http.routers.thruk.service=thruk"
        - "traefik.http.routers.thruk.rule=PathPrefix(`/demo`)"
        - "traefik.http.services.thruk.loadbalancer.server.port=80"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.port=80"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.path=/demo/thruk/cgi-bin/remote.cgi?lb_ping"
        - "traefik.http.services.thruk.loadbalancer.healthcheck.interval=3s"
    volumes:
        - ../../../:/thruk:ro
        - .:/scenario:ro
        - ../../../var/tmp:/var/tmp:rw
        - ../cluster_fixed_e2e:/test:ro
        - ../cluster_fixed_e2e/t:/test/t:ro
        - shared_var:/mnt/var
        - shared_etc:/mnt/etc
    networks:
      test.local:
        aliases:
          - thruk3.test.local
    hostname: thruk3
    domainname: test.local
    healthcheck:
      test: ["CMD", "curl", "-kf", "http://localhost/demo/"]
      interval: 10s
      timeout: 10s
      retries: 3
      start_period: 5m

volumes:
  shared_etc:
  shared_var:
