version: '3'

networks:
  net:

services:
  redis:
    image: redis:5.0.3-alpine
    ports:
      - "6379:6379"
    networks:
      - net

  ## Commenting this out because the setup is broken and is missing the config file
  # prometheus:
  #   image: prom/prometheus
  #   ports:
  #     - "9090:9090"
  #   networks:
  #     - net
  #   volumes:
  #     - ../prometheus.yml:/etc/prometheus/prometheus.yml
  #   command:
  #     - '--config.file=/etc/prometheus/prometheus.yml'

  grafana:
    image: grafana/grafana
    ports:
      - "3000:3000"
    networks:
      - net

  rq-metrics:
    image: renku/rqmetrics:latest
    container_name: rq-metrics
    depends_on:
      - redis
    environment:
      RQ_REDIS_HOST: redis
    ports:
      - "8765:8765"
    networks:
      - net

  rq-dashboard:
    image: eoranged/rq-dashboard:v0.6.1
    container_name: rq-dashboard
    depends_on:
      - redis
    environment:
      RQ_DASHBOARD_REDIS_URL: redis://redis:6379
    networks:
      - net
    ports:
      - "9181:9181"

  renku-svc:
    build:
      context: .
      dockerfile: Dockerfile.svc
    networks:
      - net
    env_file: .env
    depends_on:
      - redis
      - reverse-proxy
    ports:
      - "8080:8080"
    volumes:
      - ${PWD}:/code/renku
    command: "api --debug"
    labels:
      - "traefik.http.routers.renku-svc.rule=PathPrefix(`/api/renku`)"
      - "traefik.http.middlewares.stripprefix.stripprefix.prefixes=/api"
      - "traefik.http.routers.renku-svc.middlewares=stripprefix@docker"

  swagger:
    image: swaggerapi/swagger-ui
    networks:
      - net
    environment:
      - BASE_URL=/api/docs
      - URL=/api/renku/spec.json
    labels:
      - traefik.http.routers.swagger.rule=PathPrefix(`/api/docs`)
      - traefik.http.services.my-service.loadbalancer.server.port=8080

  renku-scheduler:
    build:
      context: .
      dockerfile: Dockerfile.svc
    command: "scheduler"
    depends_on:
      - redis
    networks:
      - net
    env_file: .env

  renku-worker:
    build:
      context: .
      dockerfile: Dockerfile.svc
    command: "worker"
    depends_on:
      - redis
    networks:
      - net
    env_file: .env

  reverse-proxy:
    image: traefik:v2.4
    command: --api.insecure=true --providers.docker
    ports:
      - "80:80"
      # set the UI port to something other than 8080 since that's our service already
      - "8088:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - net
