Skip to content

How to setup local dev nodes for apps development?

fewensa edited this page Dec 14, 2021 · 6 revisions

Create docker-compose.yml and run docker-compose up -d

services:

  crab:
    container_name: crab
    image: quay.io/darwinia-network/darwinia:v0.11.7
    volumes:
      - /data/darwinia/crab:/darwinia/data
    ports:
      - 9930:9933
      - 9940:9944
    command:
      - --base-path 
      - /darwinia/data
      - --chain
      - crab-dev
      - --unsafe-ws-external
      - --alice
      - --rpc-methods
      - Unsafe
      - --rpc-external
      - --rpc-cors
      - all

If you are directly using docker, can start with

docker run -it --name crab \
  -p 9930:9933 -p 9940:9944 \
  -v /data/darwinia/crab:/darwinia/data \
  quay.io/darwinia-network/darwinia:v0.11.7 \
  --base-path /darwinia/data \
  --chain crab-dev \
  --alice \
  --unsafe-ws-external \
  --rpc-methods Unsafe \
  --rpc-external \
  --rpc-cors all

After these being executed, 9930 9940 will be bound in local machine and 9933 9944 in the mapping container will be retained, and then, the data generated by the chain will be stored in the local /data/darwinia/crab directory. If you want to reset the chain, delete /data/ directly The darwinia/crab directory is just fine, you don't need --tmp because you want it to be in the previous state after restart.

In develop environment, using --tmp parameter is better than mount path. if you want use --tmp please delete volumes: in docker-compose.yml and delete -v parameter in docker run command. the last add --tmp parameter to command,

Use docker run -dit if you want to start the docker command in the background, and if you are using docker-compose given above, it is already started in the background. If you do not want to start in the background, execute docker-compose up, then it is not started in the background, the container will stop after Ctrl+C (edited).