# For local development run with a dummy provider
version: '3.8'
services:
  redis-server:
    # This should match the major version used in the vmpooler helm chart
    image: redis:6
    command: "redis-server --requirepass vmpooler"
    ports:
      - "6379:6379"

  redis-commander:
    image: rediscommander/redis-commander:latest
    environment:
      - REDIS_HOST=redis-server
      - REDIS_PASSWORD=vmpooler
      - HTTP_USER=admin
      - HTTP_PASSWORD=admin
    ports:
      - 8080:8081
    links:
      - redis-server

  jaeger-aio:
    image: jaegertracing/all-in-one:1
    ports:
      - "14250:14250"
      - "8081:16686"
    user: '1001'
    read_only: true
    cap_drop:
      - ALL

  vmpooler-api:
    # Uncomment image and comment out build, which will allow you to use an
    # image with local gem source instead of from a git source.
    # See build instructions in Dockerfile.local
    # image: vmpooler-local
    build:
      context: ./
      dockerfile: Dockerfile
    volumes:
      - type: bind
        source: ./data/vmpooler.yaml
        target: /etc/vmpooler/vmpooler.yaml
    ports:
      - "8082:4567"
    environment:
      - VMPOOLER_DEBUG=true # for use of dummy auth
      - VMPOOLER_CONFIG_FILE=/etc/vmpooler/vmpooler.yaml
      - REDIS_SERVER=redis-server
      - REDIS_PASSWORD=vmpooler
      - LOGFILE=/dev/null
      - VMPOOLER_TRACING_ENABLED=true
      - VMPOOLER_TRACING_JAEGER_HOST=http://jaeger-aio:14268/api/traces
    command: api
    links:
      - redis-server
      - jaeger-aio

  vmpooler-manager:
    # Uncomment image and comment out build, which will allow you to use an
    # image with local gem source instead of from a git source.
    # See build instructions in Dockerfile.local
    # image: vmpooler-local
    build:
      context: ./
      dockerfile: Dockerfile
    volumes:
      - type: bind
        source: ./data/vmpooler.yaml
        target: /etc/vmpooler/vmpooler.yaml
    ports:
      - "8083:4567"
    environment:
      - VMPOOLER_DEBUG=true # for use of dummy auth
      - VMPOOLER_CONFIG_FILE=/etc/vmpooler/vmpooler.yaml
      - REDIS_SERVER=redis-server
      - REDIS_PASSWORD=vmpooler
      - LOGFILE=/dev/null
      - VMPOOLER_TRACING_ENABLED=true
      - VMPOOLER_TRACING_JAEGER_HOST=http://jaeger-aio:14268/api/traces
    command: manager
    links:
      - redis-server
      - jaeger-aio

  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"
    links:
      - vmpooler-api
      - vmpooler-manager

  grafana:
    image: grafana/grafana-oss:latest
    volumes:
      - ./grafana/provisioning:/etc/grafana/provisioning
    ports:
     - '3000:3000'
    links:
      - prometheus
      - jaeger-aio
