diff --git a/Dockerfile b/Dockerfile index 0427321..3d11a30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,65 @@ -# Use a base image with the necessary runtime dependencies -FROM ubuntu +FROM debian:buster-slim as builder -# Install runtime dependencies -RUN apt-get update && apt-get install -y jq +ARG BITCOIN_VERSION=${BITCOIN_VERSION:-26.0} -# Copy and prepare script for signet configurations -COPY generate_signet.sh /usr/local/bin/generate_signet.sh -RUN chmod +x /usr/local/bin/generate_signet.sh +ARG TARGETPLATFORM -# Copy Bitcoin.conf file -COPY bitcoin.conf /root/.bitcoin/bitcoin.conf +RUN apt-get update && \ + apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget libc6 procps python3 +WORKDIR /tmp -# Copy the logtail.sh script -COPY logtail.sh /usr/local/bin/logtail.sh -RUN chmod +x /usr/local/bin/logtail.sh +# Install Bitcoin binaries based on platform +RUN case $TARGETPLATFORM in \ + linux/amd64) export TRIPLET="x86_64-linux-gnu";; \ + linux/arm64) export TRIPLET="aarch64-linux-gnu";; \ + esac && \ + BITCOIN_URL="https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-${TRIPLET}.tar.gz" && \ + BITCOIN_FILE="bitcoin-${BITCOIN_VERSION}-${TRIPLET}.tar.gz" && \ + wget -qO "${BITCOIN_FILE}" "${BITCOIN_URL}" && \ + mkdir -p bin && \ + tar -xzvf "${BITCOIN_FILE}" -C /tmp/bin --strip-components=2 "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-cli" "bitcoin-${BITCOIN_VERSION}/bin/bitcoind" "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-wallet" "bitcoin-${BITCOIN_VERSION}/bin/bitcoin-util" + +FROM debian:buster-slim as custom-signet-bitcoin -# Copy the .bashrc file to the container's root directory -COPY .bashrc /root/.bashrc -# Expose necessary ports (update these if needed) -EXPOSE 18443 -# EXPOSE 38333 +ENV BITCOIN_DIR /root/.bitcoin -# Start Bitcoin Core -CMD ["/usr/local/bin/generate_signet.sh"] +ENV NBITS=${NBITS} +ENV SIGNETCHALLENGE=${SIGNETCHALLENGE} +ENV PRIVKEY=${PRIVKEY} + +ENV RPCUSER=${RPCUSER:-"bitcoin"} +ENV RPCPASSWORD=${RPCPASSWORD:-"bitcoin"} +ENV COOKIEFILE=${COOKIEFILE:-"false"} +ENV I2PSAM=${I2PSAM:-""} + +ENV UACOMMENT=${UACOMMENT:-"CustomSignet"} +ENV ZMQPUBRAWBLOCK=${ZMQPUBRAWBLOCK:-"tcp://0.0.0.0:28332"} +ENV ZMQPUBRAWTX=${ZMQPUBRAWTX:-"tcp://0.0.0.0:28333"} +ENV ZMQPUBHASHBLOCK=${ZMQPUBHASHBLOCK:-"tcp://0.0.0.0:28334"} + +ENV RPCBIND=${RPCBIND:-"0.0.0.0:38332"} +ENV RPCALLOWIP=${RPCALLOWIP:-"0.0.0.0/0"} +ENV WHITELIST=${WHITELIST:-"0.0.0.0/0"} +ENV ADDNODE=${ADDNODE:-""} +ENV BLOCKPRODUCTIONDELAY=${BLOCKPRODUCTIONDELAY:-""} +ENV MINERENABLED=${MINERENABLED:-"1"} +ENV MINETO=${MINETO:-""} +ENV EXTERNAL_IP=${EXTERNAL_IP:-""} + +VOLUME $BITCOIN_DIR +EXPOSE 28332 28333 28334 38332 38333 38334 +RUN apt-get update && \ + apt-get install -qq --no-install-recommends procps python3 python3-pip jq && \ + apt-get clean +COPY --from=builder "/tmp/bin" /usr/local/bin +COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh +COPY miner /usr/local/bin/miner +COPY *.sh /usr/local/bin/ +COPY rpcauth.py /usr/local/bin/rpcauth.py +RUN pip3 install setuptools + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] + +CMD ["run.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index e69de29..cd0b011 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -eo pipefail + +shutdown_gracefully(){ + + echo "Container is shutting down, lets make sure bitcoind flushes the db." + bitcoin-cli stop + sleep 5 +} +trap shutdown_gracefully SIGTERM SIGHUP SIGQUIT SIGINT + +mkdir -p "${BITCOIN_DIR}" +# check if this is first run if so run init if config +if [[ ! -f "${BITCOIN_DIR}/install_done" ]]; then + echo "install_done file not found, running install.sh." + install.sh #this is config based on args passed into mining node or peer. +else + echo "install_done file exists, skipping setup process." + echo "rewrite bitcoin.conf" + gen-bitcoind-conf.sh >~/.bitcoin/bitcoin.conf +fi + +$@ & +echo "Infinate loop" +while true +do + tail -f /dev/null & wait ${!} +done \ No newline at end of file diff --git a/gen-bitcoind-conf.sh b/gen-bitcoind-conf.sh index 9ff7cd0..ffb96e9 100644 --- a/gen-bitcoind-conf.sh +++ b/gen-bitcoind-conf.sh @@ -49,15 +49,4 @@ fi if [[ "$I2PSAM" != "" ]]; then echo "i2psam=$I2PSAM" -fi -if [[ "$ONIONPROXY" != "" ]]; then - echo "onion=$ONIONPROXY" # unless have static IP won't resolve the control port as domain -fi - -if [[ "$TORPASSWORD" != "" ]]; then - echo "torpassword=$TORPASSWORD" -fi - -if [[ "$TORCONTROL" != "" ]]; then - echo "torcontrol=$TORCONTROL" fi \ No newline at end of file