Skip to content

Instantly share code, notes, and snippets.

@2075
Last active February 2, 2021 13:44
Show Gist options
  • Save 2075/60d0d6e91332688064bc53ee1bd4f84e to your computer and use it in GitHub Desktop.
Save 2075/60d0d6e91332688064bc53ee1bd4f84e to your computer and use it in GitHub Desktop.
quickly create a zero.io node for development from scratch

setup a node

  • this example assumes you are using e.g. ubuntu and is a simple and direct route.
  • if you want to use this in production you should take care of better security measures!

updates

sudo apt update

docker

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
rm get-docker.sh
sudo usermod -aG docker $USER

docker compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.28.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

nginx letsencrypt proxy

git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git proxy
cd proxy &&\
	docker network create webproxy &&\
	sh ./start.sh &&\
	cd ..

subzero

create node .env

NAME=MY-NODE-XYZ
IP=/dns/your.node-domain.io
PORT_P2P=30333
PORT_WSS=30334
PORT_RPC=9933
PORT_PRO=9615
DATA_DIR=~/.zero
DOMAINS=your.node-domain.io // your domain for this machine
PORT="9944"
[email protected] // your email
KEY="nodekey"
UID=0
GID=0

create docker-compose

depending on the node purpose, you should review the node options and connectivity. the node will need a security policy / firewall:

80,443	-> webproxy
9933	-> rpc
9944	-> wss
30333	-> p2p
9615	-> prometheus

set a nodekey if you want a persistent p2p address, e.g. for bootnodes

version: "3"

services:

  subzero:
    image: playzero/subzero:latest
    restart: unless-stopped
    user: "$UID:$GID"
    ports:
      - "${PORT_P2P}:30333"
      - "${PORT_WSS}:9944"
      - "${PORT_RPC}:9933"
      - "${PORT_PRO}:9615"
    volumes:
      - ${DATA_DIR}:/root/.local/share/subzero
    command: [
        "/usr/local/bin/subzero",
        "--name", "${NAME}",
        "--validator",
        "--ws-external",
        "--rpc-external",
        "--rpc-cors", "all",
        "--rpc-methods", "unsafe",
        "--public-addr","${IP}",
        "--telemetry-url", "wss://telemetry.polkadot.io/submit/ 5",
        "--node-key", "${KEY}"
      ]
    environment:
      - VIRTUAL_HOST=${DOMAINS}
      - VIRTUAL_PORT=9944
      - LETSENCRYPT_HOST=${DOMAINS}
      - LETSENCRYPT_EMAIL=${EMAIL}

networks:
  default:
    external:
      name: webproxy

questions? ping me on github or ask in our discord https://discord.com/invite/rhwtr7p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment