Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docker improvements #1

Open
wants to merge 8 commits into
base: stable/2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
#####################
# BUILD ENVIRONMENT #
#####################

FROM golang:alpine AS build_chia_exporter

WORKDIR /build

RUN apk add --update --no-cache --virtual build-dependencies git ca-certificates && \
git clone --depth 1 -b 0.12.0 https://github.com/Chia-Network/chia-exporter.git && \
cd chia-exporter && \
go build -o chia_exporter

#####################
# FINAL ENVIRONMENT #
#####################

FROM debian:stable-slim

# Identify the maintainer of an image
LABEL maintainer="[email protected]"

# Update the image to the latest packages
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git python3-virtualenv lsb-release sudo procps tmux net-tools vim iputils-ping netcat-traditional

# Install git
RUN apt-get install git python3-virtualenv lsb-release sudo procps tmux net-tools vim iputils-ping netcat-traditional golang -y
WORKDIR /root/chia-exporter
COPY --from=build_chia_exporter /build/chia-exporter/chia_exporter .

WORKDIR /root

RUN git clone --depth 1 -b v0.5.2 https://github.com/retzkek/chia_exporter.git && \
cd chia_exporter && go build

COPY . /root/chia-blockchain

WORKDIR /root/chia-blockchain

RUN sh install.sh

# Expose RPC ports
Expand All @@ -26,7 +37,7 @@ EXPOSE 8444
EXPOSE 8555
EXPOSE 9256
# Chia prometheus exporter
EXPOSE 9133
EXPOSE 9914

COPY ./docker/start.sh /root/start.sh
COPY ./docker/change_config.py /root/change_config.py
Expand Down
6 changes: 4 additions & 2 deletions docker/change_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ def main():
else:
default_node_port = 8444

config['wallet']['full_node_peer']['host'] = node_host
config['wallet']['full_node_peer']['port'] = int(os.environ.get('CHIA_NODE_PORT', default_node_port))
config['wallet']['full_node_peers'][0]['host'] = node_host
config['wallet']['full_node_peers'][0]['port'] = int(os.environ.get('CHIA_NODE_PORT', default_node_port))
else:
config['wallet'].pop('full_node_peer', None)

config['wallet']['trusted_peers'][trusted_node_id] = os.environ.get('CHIA_NODE_CRT', f'/data/chia/{chia_network}/config/ssl/full_node/public_full_node.crt')
config['wallet']['target_peer_count'] = int(os.environ.get('CHIA_PEER_COUNT', '3'))

for k, v in os.environ.items():
if not k.startswith('CHIA_WALLET_'):
Expand Down
20 changes: 16 additions & 4 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ grep -v "::" /etc/hosts > /tmp/tmphosts
cat /tmp/tmphosts > /etc/hosts

if [ ! -d "/data" ]; then
echo "No /data to persist"
echo "Error: no /data to persist"
exit 1
fi

Expand All @@ -27,7 +27,11 @@ if [ ${chia_mode} = "wallet" ]; then
chia init
fi

chia keys add -l ${WALLET_ID} -f /data/wallet_keys_${WALLET_ID:=1}
# To use docker secret (require docker swarm orchestrator)
# echo "word1 word2 word3 ..." | docker secret create wallet_keys_${WALLET_ID} -
[ -e "/run/secrets/wallet_keys_${WALLET_ID:=1}" ] && WALLET_KEY_PATH="/run/secrets"
chia keys add -l ${WALLET_ID} -f ${WALLET_KEY_PATH:=/data}/wallet_keys_${WALLET_ID:=1}

rm -rf /root/.chia/mainnet/wallet
mkdir -p /data/wallet_${WALLET_ID:=1}
ln -fs /data/wallet_${WALLET_ID:=1} /root/.chia/mainnet/wallet
Expand All @@ -49,7 +53,11 @@ if [ ${chia_mode} = "wallet" ]; then
done

if [ -n "${CHIA_EXPORTER}" ]; then
/root/chia_exporter/chia_exporter &
/root/chia-exporter/chia_exporter serve &
fi

if [ -n "${CHIA_STDOUT}" ]; then
tail -f /root/.chia/mainnet/log/debug.log &
fi

exec ./venv/bin/chia_wallet
Expand All @@ -73,7 +81,11 @@ else
done

if [ -n "${CHIA_EXPORTER}" ]; then
/root/chia_exporter/chia_exporter &
/root/chia-exporter/chia_exporter serve &
fi

if [ -n "${CHIA_STDOUT}" ]; then
tail -f /root/.chia/mainnet/log/debug.log &
fi

exec ./venv/bin/chia_full_node
Expand Down