version: '3.7'

services:
  go-nitro:
    image: cerc/go-nitro:local
    hostname: go-nitro
    restart: on-failure
    depends_on:
      # Wait for Nitro contracts to be deployed
      nitro-contracts:
        condition: service_completed_successfully
    environment:
      CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546}
      CERC_NITRO_PK: ${CERC_NITRO_PK:-f36f6dd450892224ee113899195ef922a4795d41c32cafb386d9aab6e0b7b0c6}
      CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK:-888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218}
      CERC_NITRO_USE_DURABLE_STORE: ${CERC_NITRO_USE_DURABLE_STORE:-true}
      CERC_NITRO_DURABLE_STORE_FOLDER: ${CERC_NITRO_DURABLE_STORE_FOLDER:-/app/data/nitro-store}
      CERC_NITRO_MSG_PORT: ${CERC_NITRO_MSG_PORT:-3006}
      CERC_NITRO_WS_MSG_PORT: ${CERC_NITRO_WS_MSG_PORT:-5006}
      CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT:-4006}
      CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
      CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
      CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
    entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"]
    volumes:
      - go_nitro_data:/app/data
      - nitro_deployment:/app/deployment
      - ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh
    healthcheck:
      test: ["CMD", "nc", "-vz", "localhost", "4006"]
      interval: 30s
      timeout: 5s
      retries: 10
      start_period: 10s
    ports:
      - "3006:3006"
      - "4006:4006"
      - "5006:5006"

volumes:
  go_nitro_data:
  nitro_deployment:
