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_RUN_HEADLESS=${METAMASK_RUN_HEADLESS}
    container_name: test-service-metamask
    profiles: ["5minute"]
    environment:
      CI: ${CI}
      DISPLAY: ${METAMASK_DISPLAY}
      GRAFANA_ADMIN_PWD: ${GRAFANA_ADMIN_PWD}
      PROMETHEUS_SERVER_URL: ${PROMETHEUS_SERVER_URL}
      PROMETHEUS_PUSHGATEWAY_URL: ${PROMETHEUS_PUSHGATEWAY_URL}
      METAMASK_RUN_HEADLESS: ${METAMASK_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_GOERLI_RPC_URL: ${METAMASK_OP_GOERLI_RPC_URL}
    volumes:
      - ${METAMASK_DISPLAY_VOLUME:-/path/in/container/if/no/env/set}
    restart: "no"
