version: "3"

services:
  pushgateway:
    image: prom/pushgateway
    container_name: pushgateway
    ports:
      - "9091:9091"
    restart: unless-stopped
    read_only: true
    security_opt:
      - "no-new-privileges:true"

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    read_only: true
    security_opt:
      - "no-new-privileges:true"

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PWD}
    volumes:
      - ./grafana/provisioning:/etc/grafana/provisioning
      - ./grafana/dashboards:/var/lib/grafana/dashboards
    security_opt:
      - "no-new-privileges:true"

  metamask:
    build:
      context: ./metamask
      dockerfile: Dockerfile
      args:
        - METAMASK_PLAYWRIGHT_RUN_HEADLESS=${METAMASK_PLAYWRIGHT_RUN_HEADLESS}
    container_name: test-service-metamask
    profiles: ["5minute"]
    environment:
      CI: ${CI}
      DISPLAY: ${METAMASK_DISPLAY}
      GRAFANA_ADMIN_PWD: ${GRAFANA_ADMIN_PWD}
      METRICS_READ_URL: ${METRICS_READ_URL}
      METRICS_READ_USERNAME: ${METRICS_READ_USERNAME}
      METRICS_READ_PASSWORD: ${METRICS_READ_PASSWORD}
      METRICS_WRITE_URL: ${METRICS_WRITE_URL}
      METRICS_WRITE_TOOL: ${METRICS_WRITE_TOOL}
      METRICS_WRITE_SOURCE: ${METRICS_WRITE_SOURCE}
      METRICS_WRITE_USERNAME: ${METRICS_WRITE_USERNAME}
      METRICS_WRITE_PASSWORD: ${METRICS_WRITE_PASSWORD}
      METAMASK_PLAYWRIGHT_RUN_HEADLESS: ${METAMASK_PLAYWRIGHT_RUN_HEADLESS}
      METAMASK_SECRET_WORDS_OR_PRIVATEKEY: ${METAMASK_SECRET_WORDS_OR_PRIVATEKEY}
      METAMASK_NETWORK: ${METAMASK_NETWORK}
      METAMASK_PASSWORD: ${METAMASK_PASSWORD}
      METAMASK_DAPP_URL: ${METAMASK_DAPP_URL}
      METAMASK_OP_SEPOLIA_RPC_URL: ${METAMASK_OP_SEPOLIA_RPC_URL}
    volumes:
      - ${METAMASK_DISPLAY_VOLUME:-/path/in/container/if/no/env/set}
    restart: "no"
