Skip to content

Commit

Permalink
Allow setting networks other than mainnet and the default testnet for… (
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored Nov 30, 2023
1 parent f70fd04 commit 029d93b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
WORKDIR /chia-blockchain

RUN echo "cloning ${BRANCH}" && \
git clone --depth 1 --branch ${BRANCH} --recurse-submodules=mozilla-ca https://github.com/Chia-Network/chia-blockchain.git . && \
if [ -z "$COMMIT" ]; then \
DEPTH_FLAG="--depth 1"; \
else \
DEPTH_FLAG=""; \
fi && \
git clone ${DEPTH_FLAG} --branch ${BRANCH} --recurse-submodules=mozilla-ca https://github.com/Chia-Network/chia-blockchain.git . && \
# If COMMIT is set, check out that commit, otherwise just continue
( [ ! -z "$COMMIT" ] && git fetch origin $COMMIT && git checkout $COMMIT ) || true && \
echo "running build-script" && \
Expand Down
50 changes: 50 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,61 @@ if [[ -n ${ca} ]]; then
chia ${chia_args} init -c "${ca}"
fi

# Enables whatever the default testnet is for the version of chia that is running
if [[ ${testnet} == 'true' ]]; then
echo "configure testnet"
chia configure --testnet true
fi

# Allows using another testnet that isn't the default testnet
if [[ -n ${network} ]]; then
echo "Setting network name to ${network}"
yq -i '
.selected_network = env(network) |
.seeder.selected_network = env(network) |
.harvester.selected_network = env(network) |
.pool.selected_network = env(network) |
.farmer.selected_network = env(network) |
.timelord.selected_network = env(network) |
.full_node.selected_network = env(network) |
.ui.selected_network = env(network) |
.introducer.selected_network = env(network) |
.wallet.selected_network = env(network) |
.data_layer.selected_network = env(network)
' "$CHIA_ROOT/config/config.yaml"
fi

if [[ -n ${network_port} ]]; then
echo "Setting network port to ${network_port}"
yq -i '
.seeder.port = env(network_port) |
.seeder.other_peers_port = env(network_port) |
.farmer.full_node_peers[0].port = env(network_port) |
.timelord.full_node_peers[0].port = env(network_port) |
.full_node.port = env(network_port) |
.full_node.introducer_peer.port = env(network_port) |
.introducer.port = env(network_port) |
.wallet.full_node_peers[0].port = env(network_port) |
.wallet.introducer_peer.port = env(network_port)
' "$CHIA_ROOT/config/config.yaml"
fi

if [[ -n ${introducer_address} ]]; then
echo "Setting introducer to ${introducer_address}"
yq -i '
.full_node.introducer_peer.host = env(introducer_address) |
.wallet.introducer_peer.host = env(introducer_address)
' "$CHIA_ROOT/config/config.yaml"
fi

if [[ -n ${dns_introducer_address} ]]; then
echo "Setting network port in config to ${dns_introducer_address}"
yq -i '
.full_node.dns_servers = [env(dns_introducer_address)] |
.wallet.dns_servers = [env(dns_introducer_address)]
' "$CHIA_ROOT/config/config.yaml"
fi

if [[ ${keys} == "persistent" ]]; then
echo "Not touching key directories, key directory likely mounted by volume"
elif [[ ${keys} == "none" ]]; then
Expand Down

0 comments on commit 029d93b

Please sign in to comment.