How to run local off-line ceramic nodes (with ganache - or hardhat network)?

Newbie - I’d like to run a small, local, off-line, network of test nodes. The CAS docker compose file brings up IPFS, ganache, and postgres, but fails to start the ceramic nodes. Changing the ETH_NETWORK env variables to ‘ganache’ just causes an error: Could not resolve [token “blockchainService”]. I don’t see many tutorials or introductions that do this - am I barking up the wrong tree - is this just not possible?

1 Like

Hi @stuR,

The docker compose file doesn’t get used much so it’s not always up-to-date, unfortunately :sweat_smile:

Mind sharing your updated file?

Hi @mohsin

My latest version (below) of a docker compose file still doesn’t work. There seems to be a fairly hard-coded link to use AWS for a ‘queue’ (I couldn’t figure out how to change this). I’ve been slightly demoralised today by what seems like a high entry bar. I’ve started looking at other ways to start this journey. Any suggestions for Ceramic ‘Hello World!’ tutorials would also be appreciated. I would still like to end up running a network of private Ceramic nodes / IPFS nodes / blockchain nodes etc to conduct performance testing under bandwidth limited, sharding situations etc.

version: '3.9'

services:
  cas_api:
    build: .
    environment:
      - NODE_ENV=dev
      - APP_MODE=server
      - APP_PORT=8081
      - USE_SMART_CONTRACT_ANCHORS=true

      - ANCHOR_CONTROLLER_ENABLED=true
      - ANCHOR_EXPIRATION_PERIOD=0
      - ANCHOR_SCHEDULE_EXPRESSION=0/5 * * * ? *

      - BLOCKCHAIN_CONNECTOR=ethereum
      - CERAMIC_API_URL=http://host.docker.internal:7007
      - ETH_GAS_LIMIT=6721975
      - ETH_GAS_PRICE=100000000000
      - ETH_NETWORK=ganache
      - ETH_OVERRIDE_GAS_CONFIG=false
      - ETH_CONTRACT_ADDRESS=0x4743CB4539d8bCEf0B85c987c4AeE5F8DCc8E1DE
      - ETH_RPC_HOST=http://ganache
      - ETH_RPC_PORT=8545
      - ETH_WALLET_PK=0xbf873129c72676a8ae3be570c5d6346a5722e7ebac57ed8d08dfd3d1467d6dd6

      - IPFS_API_URL=http://ipfs
      - IPFS_API_PORT=5001
      - IPFS_API_TIMEOUT=100000

      - LOG_LEVEL=debug
      - LOG_TO_FILES=true
      - LOG_PATH=/usr/local/var/log
      - MERKLE_DEPTH_LIMIT=0

      - DB_NAME=anchor_db
      - DB_HOST=database
      - DB_PORT=5432
      - DB_USERNAME=root
      - DB_PASSWORD=root

      - VALIDATE_RECORDS=false
    volumes:
      - '/usr/local/var/log:/usr/local/var/log'
    depends_on:
      - ipfs
      - database
    ports:
      - '8081:8081'
    networks:
      - internal

  cas_anchor:
    build: .
    restart: unless-stopped
    environment:
      - NODE_ENV=dev
      - APP_MODE=anchor
      - APP_PORT=8081
      - USE_SMART_CONTRACT_ANCHORS=true

      - ANCHOR_CONTROLLER_ENABLED=true
      - ANCHOR_EXPIRATION_PERIOD=0
      - ANCHOR_SCHEDULE_EXPRESSION=0/5 * * * ? *

      - BLOCKCHAIN_CONNECTOR=ethereum
      - CERAMIC_API_URL=http://host.docker.internal:7007
      - ETH_GAS_PRICE=100000000000
      - ETH_NETWORK=ganache
      - ETH_OVERRIDE_GAS_CONFIG=false
      - ETH_CONTRACT_ADDRESS=0x4743CB4539d8bCEf0B85c987c4AeE5F8DCc8E1DE
      - ETH_RPC_HOST=http://ganache
      - ETH_RPC_PORT=8545
      - ETH_WALLET_PK=0xbf873129c72676a8ae3be570c5d6346a5722e7ebac57ed8d08dfd3d1467d6dd6

      - IPFS_API_URL=http://ipfs
      - IPFS_API_PORT=5001
      - IPFS_API_TIMEOUT=100000

      - LOG_LEVEL=debug
      - LOG_TO_FILES=true
      - LOG_PATH=/usr/local/var/log
      - MERKLE_DEPTH_LIMIT=0

      - DB_NAME=anchor_db
      - DB_HOST=database
      - DB_PORT=5432
      - DB_USERNAME=root
      - DB_PASSWORD=root

      - VALIDATE_RECORDS=false
    volumes:
      - '/usr/local/var/log:/usr/local/var/log'
    depends_on:
      - ipfs
      - database
      - cas_api
    networks:
      - internal

  ipfs:
    image: ipfs/kubo
    command:
      - "daemon"
      - "--enable-pubsub-experiment"
    volumes:
      - './export:/export'
      - './data/ipfs:/data/ipfs'
    ports:
      - '5001:5001'
      - '4001:4001'
      - '8080:8080'
    networks:
      - internal

  database:
    image: 'postgres'
    environment:
      - POSTGRES_USER=root
      - POSTGRES_PASSWORD=root
      - POSTGRES_DB=anchor_db
    ports:
      - '5432:5432'
    volumes:
      - ./data/postgres:/var/lib/postgresql/data/
    networks:
      - internal

  ganache:
    image: trufflesuite/ganache
    ports:
      - '8545:8545'
    command:
      - "--mnemonic='move sense much taxi wave hurry recall stairs thank brother nut woman' --networkId=1377 --hostname=127.0.0.1 -l=80000000"
    networks:
      - internal

networks:
  internal:
    driver: bridge

@stuR so if you’re only trying to do some local testing as a builder on ceramic, we use an in memory network in our samples (and you don’t need to run CAS etc). Check out our wheel cli that can be used to spin up a ceramic node using a sample app, if interested.

As it sounds like you’re interested in running a network and doing some more complex tests, I’d suggest you take a look at our Keramik project. It’s tooling we use to deploy a Kubernetes cluster of a Ceramic network for testing. It includes all the pieces: ceramic, IPFS, CAS, postgres, ganache, etc.

You would want to use kubo (go IPFS). We’re currently focused on benchmarking our upcoming rust-ceramic release with the recon protocol so the defaults aren’t quite what you’d want. Here is a sample yaml file you could use to define a network that would create two ceramic nodes as peers using a local CAS with mocked dependencies. The keramik docs should have some information about configuration options and how to run things.

apiVersion: "keramik.3box.io/v1alpha1"
kind: Network
metadata:
  name: small
spec:
  replicas: 2
  cas:
    ipfs:
      go: {} 
  ceramic:
    - ipfs:
        go: {} 
      env:
        CERAMIC_PUBSUB_QPS_LIMIT: "1000"

I will take a look at the dockerfile you posted… there might be a couple variables to set that will allow you do it that way, but I think Keramik will be a much simpler path to running an offline network.

3 Likes

@david

Great observation and advice - thank you. It does look like I was starting to slowly re-invent your Keramik project. I will switch focus to that - with some joy.

4 Likes