version: '3'

services:
  destination:
    build:
      context: .
      dockerfile: controller/Dockerfile
      args:
      - CONDUIT_VERSION=latest
    ports:
    - "8089:8089"
    - "9999:9999"
    volumes:
    - ~/.kube/config:/kubeconfig:ro
    command:
    - destination
    - -addr=:8089
    - -metrics-addr=:9999
    - -kubeconfig=/kubeconfig

  tap:
    build:
      context: .
      dockerfile: controller/Dockerfile
      args:
      - CONDUIT_VERSION=latest
    ports:
    - "8088:8088"
    - "9998:9998"
    volumes:
    - ~/.kube/config:/kubeconfig:ro
    command:
    - tap
    - -addr=:8088
    - -metrics-addr=:9998
    - -kubeconfig=/kubeconfig

  proxy-api:
    build:
      context: .
      dockerfile: controller/Dockerfile
      args:
      - CONDUIT_VERSION=latest
    ports:
    - "8086:8086"
    - "9996:9996"
    command:
    - proxy-api
    - -addr=:8086
    - -metrics-addr=:9996
    - -destination-addr=destination:8089

  public-api:
    build:
      context: .
      dockerfile: controller/Dockerfile
      args:
      - CONDUIT_VERSION=latest
    ports:
    - "8085:8085"
    - "9995:9995"
    volumes:
    - ~/.kube/config:/kubeconfig:ro
    command:
    - public-api
    - -addr=:8085
    - -metrics-addr=:9995
    - -tap-addr=tap:8088
    - -prometheus-url=http://prometheus:9090
    - -kubeconfig=/kubeconfig

  web:
    build:
      context: .
      dockerfile: web/Dockerfile
      args:
      - CONDUIT_VERSION=latest
    ports:
    - "8084:8084"
    - "9994:9994"
    command:
    - -addr=:8084
    - -metrics-addr=:9994
    - -api-addr=public-api:8085
    - -static-dir=/dist
    - -template-dir=/templates

  prometheus:
    image: prom/prometheus:v2.2.1
    ports:
    - 9090:9090
    volumes:
    - .prometheus.dev.yml:/etc/prometheus/prometheus.yml:ro
    command:
    - --config.file=/etc/prometheus/prometheus.yml
    - --storage.tsdb.retention=6h

  grafana:
    build:
      context: .
      dockerfile: grafana/Dockerfile
    ports:
    - 3000:3000
    volumes:
    - ./grafana/dev.grafana.ini:/etc/grafana/grafana.ini:ro
    - ./grafana/dev.dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml:ro
    - ./grafana/dev.datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml:ro

  simulate-proxy:
    image: golang:1.10.0-alpine3.7
    ports:
    - 10000-10009:10000-10009
    volumes:
    - .:/go/src/github.com/runconduit/conduit
    - ~/.kube/config:/kubeconfig:ro
    command:
    - go
    - run
    - /go/src/github.com/runconduit/conduit/controller/script/simulate-proxy/main.go
    - --metric-ports=10000-10009
    - --kubeconfig=/kubeconfig
    - --sleep=3s
