🐳Docker

Authors: [Vince | Nodeify]

System Requirements

CPUOSRAMDISK

4c/8t CPU

Ubuntu 22.04

16GB+

>= 5TB SSD/NVME

Avalanche Go ⛰

Official Docs

https://docs.avax.network/nodes

Pre-requisites

Update, upgrade, and clean the system, and then firewall management (ufw), Docker, and the Git version control system.

sudo apt update -y && sudo apt upgrade -y && sudo apt auto-remove -y
sudo apt install docker.io docker-compose git ufw -y

Set explicit default UFW rules

sudo ufw default deny incoming
sudo ufw default allow outgoing

Allow SSH, HTTP and HTTPS

sudo ufw allow 22/tcp
sudo ufw allow 80
sudo ufw allow 443

Get the IP address of the host machine, you can use the following command in a terminal or command prompt

curl ifconfig.me

Set an A record for a domain, you need to access the domain's DNS settings and create an A record that points to the IP address of the host machine. This configuration allows users to reach your domain by resolving the domain name to the specific IP address associated with your host machine.

Create Avalanche directory

The first command, mkdir avalanche, will create a new directory named avalanche in the current location. The second command, cd avalanche, will change your current working directory to the newly created avalanche directory. Now you are inside the avalanche directory and can start storing docker-compose and related files in it.

mkdir avalanche
cd avalanche

Create .env file

sudo nano .env

Paste the following into the file.

EMAIL={YOUR_EMAIL} #Your email to receive SSL renewal emails
DOMAIN={YOUR_DOMAIN} #Domain of your reth node you set earlier, reth.indexerdao.com
WHITELIST={YOUR_REMOTE_MACHINE_IP} # Remote IP's allowed to connect to RPC

ctrl + x and y to save file

Create docker-compose.yml

sudo nano docker-compose.yml

Paste the following into the docker-compose.yml

version: '3.8'

networks:
  monitor-net:
    driver: bridge

volumes:
  avax_data: {}
  traefik_letsencrypt: {}

services:

######################################################################################
#####################         TRAEFIK PROXY CONTAINER          #######################
######################################################################################     

  traefik:
    image: traefik:latest
    container_name: traefik
    restart: always
    ports:
      - "443:443"
    networks:
      - monitor-net
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--api.dashboard=true"
      - "--log.level=DEBUG"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.myresolver.acme.email=$EMAIL"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
    volumes:
      - "traefik_letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.ipwhitelist.ipwhitelist.sourcerange=$WHITELIST"

######################################################################################
#####################               AVAX CONTAINER             #######################
######################################################################################     

  avax:
    image: avaplatform/avalanchego:v1.10.7
    container_name: avax
    restart: unless-stopped
    expose:
      - "9650" # RPC
      - "9650" #/ext/metrics
    ports:
      - "9651:9651/tcp"
      - "9651:9651/udp"
    networks:
      - monitor-net
    command:
      - "/avalanchego/build/avalanchego --http-host="
    volumes:
      - avax_data:/root/.avalanchego
      - ./archive-config.json:/root/.avalanchego/configs/chains/C/config.json
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.avax-replacepath.replacepath.path=/ext/bc/C/rpc"
      - "traefik.http.services.avalanche.loadbalancer.server.port=9650"
      - "traefik.http.routers.avax.entrypoints=websecure"
      - "traefik.http.routers.avax.tls.certresolver=myresolver"
      - "traefik.http.routers.avax.rule=Host(`$DOMAIN`)"
      - "traefik.http.routers.avax.middlewares=ipwhitelist"

ctrl + x and y to save file

Download archive-config.json

wget https://github.com/kw1knode/node-vault/blob/main/avalanche/docker/archive-config.json

Run Avalanche Node

docker-compose up -d

Monitor Logs

Use docker logs to monitor your Avalanche node. The -f flag ensures you are following the log output

docker logs avax -f

Test Avalanche RPC 🧪

curl --data '{"method":"eth_syncing","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://{DOMAIN}

You should receive this result when synced.

{"jsonrpc":"2.0","id":1,"result":false}

Last updated