Skip to content

Instantly share code, notes, and snippets.

@bitraft
Forked from snikch/.env.example
Created May 11, 2021 15:24
Show Gist options
  • Save bitraft/43cdd344e55118f685add2fa145d6802 to your computer and use it in GitHub Desktop.
Save bitraft/43cdd344e55118f685add2fa145d6802 to your computer and use it in GitHub Desktop.
Chia Network Docker Compose
PLOTS_TMP_DIR=/mnt/scratch/plots
PLOTS_FINAL_DIR=/mnt/storage/plots

Chia Network w/ Docker

This makes using the Chia network very easy, especially via CLI as Chia have now moved to an electron app. Testing with beta-1.0b8-dev at time of writing.

Prerequisites

Build the docker image

docker build -t chia .

Set up ENV

Set up a .env file, see .env.example. You'll want a fast drive for tmp, and a big drive for final. Worst case, just use the same drive.

Config

An example config.yaml will be added soon, however here is a list of the modifications that need to be made.

  • Replace 127.0.0.1 with the appropriate host. Since each process runs as a container at a unique hostname (the service name), we need to direct traffic to the correct host. This is generally replacing the key xxx_peer: 127.0.0.1 to xxx_peer: xxx, e.g. farmer_peer: farmer since the farmer will be available at the hostname farmer.
  • Set start_rpc_server: false. We don't need the rpc server, as it is designed to allow interprocess communication when everything is all running and hidden, and to manage services / processes. We interact directly by running and stopping docker containers instead.
  • Update plots.yml to change your local dir to the mounted dir, i.e. /plots-final/plot-knn-yyyy-mm-dd-hh-MM-xxxxxxxxxx.dat.

Running

Init

# Init your config
docker-compose run init

# Generate your keys
docker-compose run generate_keys

Plots

# Start Generating some Plots
docker-compose up -d create_plots
# Alternate invocation
docker-compose up -d -e PLOT_K=30 -e PLOT_N=10 create_plots

Farming

docker-compose up -d full_node
docker-compose up -d farmer
docker-compose up -d harvester

TODO

  • config.yml with appropriate hosts and ports for running components internally
version: '2.2'
x-base: &base
image: chia
volumes:
- ${CHIA_ROOT:-~/.chia}:/root/.chia/
- ${PLOTS_TMP_DIR?}:/plots-tmp
- ${PLOTS_FINAL_DIR?}:/plots-final
- ${CHIA_KEYRING_ROOT:-~/.local/share/python_keyring/}:/root/.local/share/python_keyring/
services:
# Base chia command, useful for arbitrary chia runs, e.g.
# docker-compose run chia keys show
chia:
<<: *base
entrypoint: chia
init:
<<: *base
command: chia init
generate_keys:
<<: *base
command: chia keys generate
create_plots:
<<: *base
command:
- chia-create-plots
- -k ${PLOT_K:-30}
- -n ${PLOT_N:-1}
- -t /plots-tmp
- -2 /plots-tmp
- -d /plots-final
full_node:
<<: *base
#command: chia_full_node
command: python3 src/server/start_full_node.py
farmer:
<<: *base
#command: chia_farmer
command: python3 src/server/start_farmer.py
harvester:
<<: *base
#command: chia_harvester
command: python3 src/server/start_harvester.py
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y python3.8-venv python3.8-distutils python3-pip git
RUN git clone https://github.com/Chia-Network/chia-blockchain.git /opt/chia-blockchain
WORKDIR /opt/chia-blockchain
# Temp workaround until 1.0beta8 is release to master.
RUN git checkout dev
RUN python3.8 -m pip install wheel
RUN python3.8 -m pip install -i https://download.chia.net/simple/ miniupnpc==2.1 setproctitle==1.1.10 cbor2==5.1.0
RUN python3.8 -m pip install -e .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment