version: "3"
services:
  go-application:
    build:
      context: ./go-application
    container_name: go-application
    image: go-application
    ports:
      - "80:5000"
  python-application:
    build:
      context: ./python-application
    container_name: python-application
    image: python-application
    ports:
      - "81:5000"
  dotnet-application:
    build:
      context: ./dotnet-application
    container_name: dotnet-application
    image: dotnet-application
    ports:
      - "82:5000"
  nodejs-application:
    build:
      context: ./nodejs-application
    container_name: nodejs-application
    image: nodejs-application
    ports:
      - "83:5000"
  prometheus:
    container_name: prometheus-svc
    image: prom/prometheus
    ports: 
      - "9091:9090"
    command: --config.file=/etc/prometheus/prometheus.yaml
    volumes:
      - ./prometheus.yaml:/etc/prometheus/prometheus.yaml
  grafana:
    image: grafana/grafana:5.0.4
    ports:
      - "3000:3000"
    environment:
      - GF_AUTH_BASIC_ENABLED=false
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
  grafana-dashboards:
    image: alpine:3.10
    depends_on:
      - grafana
    volumes:
      - ./grafana-data:/grafana
    command: >
      /bin/sh -c "
        apk add --no-cache curl
        echo 'waiting for grafana'
        sleep 5s
        cd /grafana
        curl --request POST http://grafana:3000/api/datasources --header 'Content-Type: application/json' -d @datasources.json
        curl --request POST http://grafana:3000/api/dashboards/db --header 'Content-Type: application/json' -d @dashboard.json"