# Author: Martin Ptacek

# This docker compose file spins up the following containers:
#   - nginx reverse proxy
#   - prometheus time-series database
#   - grafana monitoring dashboard
#   - pushprox prometheus proxy for traversing NAT 

version: '3.9'

services:

  grafana:
    container_name: grafana
    hostname: grafana
    image: grafana/grafana:8.5.22
    restart: on-failure
    networks:
      - common-network
    volumes:
      - grafana-data:/var/lib/grafana
      - ./configuration/grafana_prometheus.yml:/etc/grafana/provisioning/datasources/grafana_prometheus.yml

  nginx:
    container_name: nginx
    image: nginx:1.23.4
    volumes:
      - ./configuration/nginx.conf:/etc/nginx/nginx.conf
    ports:
      - 3000:3000 # grafana port
      - 8080:8080 # pushprox port
      - 9090:9090 # prometheus UI port
    networks:
      - common-network
    restart: on-failure

  pushprox:
    container_name: pushprox
    hostname: pushprox
    image: prometheuscommunity/pushprox:master
    networks:
      - common-network

  prometheus:
    container_name: prometheus
    hostname: prometheus
    image: bitnami/prometheus:2.43.0
    restart: on-failure
    command: "--config.file=/etc/prometheus/prometheus.yml --enable-feature=remote-write-receiver"
    volumes:
      - ./configuration/prometheus.yaml:/etc/prometheus/prometheus.yml
    networks:
      - common-network

volumes:
  grafana-data:

networks:
  common-network:
    driver: bridge
