version: '3.1'

services:
  optimism-dtl:
    image: ethereumoptimism/data-transport-layer:${IMAGE_TAG__DTL:-latest}
    restart: unless-stopped
    user: root
    entrypoint:
      - /bin/sh
      - -c
      - "/scripts/dtl-start.sh"
    env_file:
      - ./optimism/env/dtl.env
      - .env
    volumes:
      - optimism-dtl:/db
      - ./optimism/scripts/:/scripts/
    environment:
      - "SYNC_SOURCE=l2"
      - "DATA_TRANSPORT_LAYER__RPC_ENDPOINT=${OPTIMISM_L2_URL}"
    networks:                                                                                        
      - chains

  optimism-l2geth:
    image: ethereumoptimism/l2geth:${IMAGE_TAG__L2GETH:-latest}
    restart: unless-stopped
    stop_grace_period: 3m
    user: root
    entrypoint:
      - /bin/sh
      - -c
      - "/scripts/l2geth-init.sh && /scripts/l2geth-start.sh"
    env_file:
      - ./optimism/env/l2geth.env
      - .env
    volumes:
      - optimism-geth:/geth
      - ./optimism/scripts/:/scripts/
    expose:
      - 8545 # http
      - 8546 # ws
      - 33289 # P2P
    ports:
      - "33289:33289"
      - "33289:33289/udp"
    environment:
      - "NODE_TYPE=archive"
      - "SYNC_SOURCE=l2"
      - "WS_PORT=8546"
    networks:                                                                                         
      - chains

    
  optimism-op-geth:
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.11.2-13ee9ab
    restart: unless-stopped
    stop_grace_period: 5m
    expose:
      - "9090"
      - "8545"
      - "8551"
    command: >
      --datadir="/datadir"
      --http
      --http.corsdomain="*"
      --http.vhosts="*"
      --http.addr=0.0.0.0
      --http.port=8545
      --http.api=web3,debug,eth,txpool,net,engine
      --ws
      --ws.addr=0.0.0.0
      --ws.port=8545
      --ws.origins="*"
      --ws.api=debug,eth,txpool,net,engine,web3
      --syncmode=full
      --gcmode="archive"
      --nodiscover
      --maxpeers=0
      --networkid=420
      --authrpc.vhosts="*"
      --authrpc.addr=0.0.0.0
      --authrpc.port=8551
      --authrpc.jwtsecret=/jwtsecret
      --rollup.sequencerhttp="https://mainnet-sequencer.optimism.io"
      --rollup.disabletxpoolgossip=true
      --rollup.historicalrpc=http://optimism-l2geth:8545
    volumes:
      - optimism-op-geth:/datadir
      - .jwtsecret:/jwtsecret
    networks:
      - chains
    labels:
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=6060"
      - "prometheus-scrape.job_name=optimism"
      - "prometheus-scrape.metrics_path=/debug/metrics/prometheus"
      - "traefik.enable=true"
      - "traefik.http.middlewares.optimism-archive-stripprefix.stripprefix.prefixes=/optimism-archive"
      - "traefik.http.services.optimism-archive.loadbalancer.server.port=8545"
      - "traefik.http.routers.optimism-archive.entrypoints=websecure"
      - "traefik.http.routers.optimism-archive.tls.certresolver=myresolver"
      - "traefik.http.routers.optimism-archive.rule=Host(`$DOMAIN`) && PathPrefix(`/optimism-archive`)"
      - "traefik.http.routers.optimism-archive.middlewares=optimism-archive-stripprefix, ipwhitelist"
  
      
  optimism-op-erigon:
    image: testinprod/op-erigon:2.48.1-0.1.10-amd64
    restart: unless-stopped
    stop_grace_period: 5m
    expose:
      - "9090"
      - "8545"
      - "8551"
    command: >
      --private.api.addr=localhost:9090
      --http.api=eth,debug,net,trace,web3,erigon
      --http.addr=0.0.0.0
      --http.port=8545
      --http.corsdomain="*"
      --http.vhosts="*"
      --authrpc.addr=0.0.0.0
      --authrpc.port=8551
      --authrpc.vhosts="*"
      --authrpc.jwtsecret=/jwtsecret      
      --rollup.sequencerhttp="https://mainnet-sequencer.optimism.io"
      --rollup.historicalrpc="http://optimism-l2geth:8545"
      --chain=optimism-mainnet
      --ws
      --nodiscover
    volumes:
      - erigon-optimism-bedrock:/root/.local/share/erigon
      - .jwtsecret:/jwtsecret
    networks:
      - chains
    labels:
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=6060"
      - "prometheus-scrape.job_name=optimism-erigon"
      - "prometheus-scrape.metrics_path=/debug/metrics/prometheus"
      - "traefik.enable=true"
      - "traefik.http.middlewares.optimism-erigon-stripprefix.stripprefix.prefixes=/optimism-erigon"
      - "traefik.http.services.optimism-erigon.loadbalancer.server.port=8545"
      - "traefik.http.routers.optimism-erigon.entrypoints=websecure"
      - "traefik.http.routers.optimism-erigon.tls.certresolver=myresolver"
      - "traefik.http.routers.optimism-erigon.rule=Host(`$DOMAIN`) && PathPrefix(`/optimism-erigon`)"
      - "traefik.http.routers.optimism-erigon.middlewares=optimism-erigon-stripprefix, ipwhitelist"


  optimism-op-node:
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:v1.1.0
    restart: unless-stopped
    stop_grace_period: 5m
    environment:
      - OPTIMISM_L1_URL=${OPTIMISM_L1_URL}
      - OPTIMISM_L1_TYPE=${OPTIMISM_L1_TYPE:-basic}
    command: >
      op-node
      --l1=$OPTIMISM_L1_URL
      --l2=http://optimism-op-geth:8551
      --network=mainnet
      --rpc.addr=0.0.0.0
      --rpc.port=9545
      --l2.jwt-secret=/jwtsecret
      --l1.trustrpc
      --l1.rpckind=$OPTIMISM_L1_TYPE
      --metrics.enabled
      --metrics.addr=0.0.0.0
      --metrics.port=7300    
    networks:
      - chains
    volumes:
      - .jwtsecret:/jwtsecret


  optimism-op-node-erigon:
    image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:v1.1.0
    restart: unless-stopped
    stop_grace_period: 5m
    environment:
      - OPTIMISM_L1_URL=${OPTIMISM_L1_URL}
      - OPTIMISM_L1_TYPE=${OPTIMISM_L1_TYPE:-basic}
    command: >
      op-node
      --l1=$OPTIMISM_L1_URL
      --l2=http://optimism-op-erigon:8551
      --network=mainnet
      --rpc.addr=0.0.0.0
      --rpc.port=9545
      --l2.jwt-secret=/jwtsecret
      --l1.trustrpc
      --l1.rpckind=$OPTIMISM_L1_TYPE
      --metrics.enabled
      --metrics.addr=0.0.0.0
      --metrics.port=7300    
    networks:
      - chains
    volumes:
      - .jwtsecret:/jwtsecret

      
volumes:
  optimism-dtl:
  optimism-geth:
  optimism-op-geth:
  erigon-optimism-bedrock:
