version: '3.7'

services:
  fixturenet-optimism-contracts:
    hostname: fixturenet-optimism-contracts
    image: cerc/optimism-contracts:local
    depends_on:
      fixturenet-eth-geth-1:
        condition: service_healthy
      fixturenet-eth-bootnode-lighthouse:
        condition: service_healthy
    environment:
      CHAIN_ID: 1212
      L1_RPC: "http://fixturenet-eth-geth-1:8545"
    command: "./run.sh"
    volumes:
      - ../config/fixturenet-optimism/optimism-contracts/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts
      - ../config/fixturenet-optimism/optimism-contracts/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts
      - ../config/fixturenet-optimism/optimism-contracts/update-config.js:/app/packages/contracts-bedrock/update-config.js
      - ../config/fixturenet-optimism/optimism-contracts/run.sh:/app/packages/contracts-bedrock/run.sh
      - fixturenet_geth_accounts:/geth-accounts:ro
      - l2_accounts:/l2-accounts
      - l1_deployment:/app/packages/contracts-bedrock

  op-node-l2-config-gen:
    image: cerc/optimism-op-node:local
    depends_on:
      fixturenet-optimism-contracts:
        condition: service_completed_successfully
    environment:
      L1_RPC: "http://fixturenet-eth-geth-1:8545"
    volumes:
      - ../config/fixturenet-optimism/generate-l2-config.sh:/app/generate-l2-config.sh
      - l1_deployment:/contracts-bedrock:ro
      - op_node_data:/app
    command: ["sh", "/app/generate-l2-config.sh"]

  op-geth:
    image: cerc/optimism-l2geth:local
    depends_on:
      op-node-l2-config-gen:
        condition: service_started
    volumes:
      - ../config/fixturenet-optimism/run-op-geth.sh:/run-op-geth.sh
      - op_node_data:/op-node:ro
      - l2_accounts:/l2-accounts:ro
    entrypoint: "sh"
    command: "/run-op-geth.sh"
    ports:
      - "8545"
    healthcheck:
      test: ["CMD", "nc", "-vz", "localhost:8545"]
      interval: 30s
      timeout: 10s
      retries: 10
      start_period: 10s

  op-node:
    environment:
      L1_RPC: "http://fixturenet-eth-geth-1:8545"
    depends_on:
      op-geth:
        condition: service_healthy
    image: cerc/optimism-op-node:local
    volumes:
      - ../config/fixturenet-optimism/run-op-node.sh:/app/run-op-node.sh
      - op_node_data:/op-node-data:ro
      - l2_accounts:/l2-accounts:ro
    command: ["sh", "/app/run-op-node.sh"]
    ports:
      - "8547"
    healthcheck:
      test: ["CMD", "nc", "-vz", "localhost:8547"]
      interval: 30s
      timeout: 10s
      retries: 10
      start_period: 10s

  op-batcher:
    environment:
      L1_RPC: "http://fixturenet-eth-geth-1:8545"
    depends_on:
      fixturenet-eth-geth-1:
        condition: service_healthy
      op-node:
        condition: service_healthy
      op-geth:
        condition: service_healthy
    image: cerc/optimism-op-batcher:local
    volumes:
      - ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh
      - l2_accounts:/l2-accounts:ro
    entrypoint: "sh"
    command: "/run-op-batcher.sh"

volumes:
  op_node_data:
  l2_accounts:
  l1_deployment:
