version: "3.2"

services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    networks:
      - testbed
    ports:
      - 9090:9090
    command:
      - --config.file=/etc/prometheus/prometheus.yml
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
    depends_on:
      - cadvisor
  cadvisor:
    image: zcube/cadvisor:latest
    container_name: cadvisor
    networks:
      - testbed
    ports:
      - 8080:8080
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /dev/disk/:/dev/disk:ro
  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    networks:
      - testbed
    ports:
      - "3000:3000"
    depends_on:
      - prometheus
    volumes:
      - ./grafana_provisioning:/etc/grafana/provisioning
    environment:
      GF_SECURITY_ADMIN_USER: admin
      GF_SECURITY_ADMIN_PASSWORD: 1234
      GF_AUTH_ANONYMOUS_ENABLED: "true"
      GF_AUTH_ANONYMOUS_ORG_ROLE: "Viewer"
      GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /etc/grafana/provisioning/dashboards/ddos.json
  victim:
    image: httpd:2.2.34
    container_name: victim
    cap_add:
      - NET_ADMIN
    networks:
      - testbed
    cpu_period: 100000
    cpu_quota: 100000
    mem_limit: 500m
    memswap_limit: 500m
    ports:
      - "80:80"
    volumes:
      - ./apache_configs/httpd_2.2.34.conf:/usr/local/apache2/conf/httpd.conf
    restart: always
  apache_exporter:
    image: lusotycoon/apache-exporter
    command: --scrape_uri="http://victim/server-status?auto"
    ports:
      - "9117:9117"
    networks:
      - testbed
    container_name: apache_exporter
    depends_on:
      - victim
networks:
  testbed:
    driver: bridge
    name: testbed
    ipam:
      driver: default
    internal: false #if it was true here, the network would be completely isolated

