commit 49ed9947e7b65055483fa23b9b4474db9c9e88cc Author: George Tankersley Date: Fri Sep 6 17:59:27 2019 -0400 dockerfiles: add binary zcashd base container diff --git a/dockerfiles/zcashd/Dockerfile b/dockerfiles/zcashd/Dockerfile new file mode 100644 index 0000000..b07eb4b --- /dev/null +++ b/dockerfiles/zcashd/Dockerfile @@ -0,0 +1,35 @@ +FROM debian:buster-slim + +RUN apt-get update && apt-get install -y -q curl + +RUN adduser --uid 1000 --system zcash && \ + mkdir -p /home/zcash/.zcash/ && \ + mkdir -p /home/zcash/.zcash-params/ && \ + chown -R zcash /home/zcash && \ + echo "Initialized user 'zcash'" + +COPY download-zcashd.sh /home/zcash/ +COPY generate-config.sh /home/zcash/ + +USER zcash + +WORKDIR /home/zcash/ + +ENV FILENAME "zcash-2.0.7-2-linux64-debian-stretch.tar.gz" +ENV EXPECTED_HASH "597d169606ed2d1b621d80f39c06291ff01d57cae8f178c0d6e90df1a27405ed" + +# This should fail if the hash does not match the expected hash. +RUN ./download-zcashd.sh + +# Create a zcash.conf for testnet with random RPC credentials +RUN ./generate-config.sh +RUN mv ./zcash.conf /home/zcash/.zcash/ + +# Extract the tarball. +RUN tar xvf $FILENAME + +# Change this for each new version. +WORKDIR ./zcash-2.0.7-2 + +VOLUME [/home/zcash/.zcash] +VOLUME [/home/zcash/.zcash-params] diff --git a/dockerfiles/zcashd/download-zcashd.sh b/dockerfiles/zcashd/download-zcashd.sh new file mode 100755 index 0000000..38d04da --- /dev/null +++ b/dockerfiles/zcashd/download-zcashd.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -euxo pipefail + +WORKDIR=`pwd` + +function download_zcashd { + EXPECTED_HASH=${EXPECTED_HASH:-"597d169606ed2d1b621d80f39c06291ff01d57cae8f178c0d6e90df1a27405ed"} + FILENAME=${FILENAME:-"zcash-2.0.7-2-linux64-debian-stretch.tar.gz"} + #BASE_URL_ZCASH="https://z.cash/downloads" + BASE_URL_MIRROR="https://storage.googleapis.com/zcashd-release-mirror/zcash-2.0.7-2" + + DOWNLOAD_DIR=`mktemp -d` + + cd ${DOWNLOAD_DIR} + + curl -OL ${BASE_URL_MIRROR}/${FILENAME} + + cat <<- EOF > ${DOWNLOAD_DIR}/SHA256SUMS + ${EXPECTED_HASH} ${FILENAME} + EOF + + if sha256sum -c ${DOWNLOAD_DIR}/SHA256SUMS; then + echo "DOWNLOAD OK" + cp ${FILENAME} ${WORKDIR}/ + rm -rf ${DOWNLOAD_DIR} + return + fi + + echo "DOWNLOAD SAYS NOPE" + rm -rf ${DOWNLOAD_DIR} + exit 1 +} + +download_zcashd diff --git a/dockerfiles/zcashd/generate-config.sh b/dockerfiles/zcashd/generate-config.sh new file mode 100755 index 0000000..014896e --- /dev/null +++ b/dockerfiles/zcashd/generate-config.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -euxo pipefail + +WORKDIR=`pwd` + +function generate_config { + RPC_USER=$(head -c 32 /dev/urandom | base64) + RPC_PASS=$(head -c 32 /dev/urandom | base64) + + cat <<- EOF > ${WORKDIR}/zcash.conf + testnet=1 + addnode=testnet.z.cash + rpcport=8232 + rpcuser=${RPC_USER} + rpcpassword=${RPC_PASS} + EOF +} + +generate_config