Docker bitcoind fixes and cleanup

pull/264/head
Andreas M. Antonopoulos 4 years ago
parent 2ef545545e
commit 25a3f35113

@ -19,12 +19,16 @@ ADD $GH_URL/contrib/bitcoin-cli.bash-completion $BC/bitcoin-cli
ADD $GH_URL/contrib/bitcoind.bash-completion $BC/bitcoind
ADD $GH_URL/contrib/bitcoin-tx.bash-completion $BC/bitcoin-tx
ADD bashrc /root/.bashrc
FROM bitcoind-base AS bitcoind-regtest
ADD bitcoind /bitcoind
RUN ln -s /bitcoind /root/.bitcoin
RUN ln -s /bitcoind /root/.
ADD bashrc /root/.bashrc
ADD bitcoind-entrypoint.sh /usr/local/bin
RUN chmod +x /usr/local/bin/bitcoind-entrypoint.sh
ADD mine.sh /usr/local/bin
RUN chmod +x /usr/local/bin/mine.sh
# bitcoind P2P
EXPOSE 18444/tcp
@ -36,5 +40,7 @@ EXPOSE 12005/tcp
EXPOSE 12006/tcp
WORKDIR /bitcoind
CMD /bin/bash /bitcoind/bitcoind-start.sh \
&& /bin/bash /bitcoind/mine.sh
ENTRYPOINT ["/usr/local/bin/bitcoind-entrypoint.sh"]
# Mine new block every 10 seconds
CMD ["/usr/local/bin/mine.sh"]

@ -1,3 +1,5 @@
# Use bash-completion, if available
alias bitcoin-cli="bitcoin-cli -datadir=/bitcoind"
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
. /usr/share/bash-completion/bash_completion

@ -1,7 +1,13 @@
#!/bin/bash
set -Eeuo pipefail
echo Starting bitcoind...
bitcoind -datadir=/bitcoind -daemon
sleep 5
until bitcoin-cli -datadir=/bitcoind getblockchaininfo > /dev/null 2>&1
do
sleep 1
done
echo bitcoind started
export address=`cat /bitcoind/keys/demo_address.txt`
export privkey=`cat /bitcoind/keys/demo_privkey.txt`
echo "================================================"
@ -10,3 +16,7 @@ echo "Bitcoin address: " ${address}
echo "Private key: " ${privkey}
echo "================================================"
bitcoin-cli -datadir=/bitcoind importprivkey $privkey
# Executing CMD
echo "$@"
exec "$@"

@ -1,4 +1,5 @@
#!/bin/bash
set -Eeuo pipefail
export address=`cat /bitcoind/keys/demo_address.txt`
export privkey=`cat /bitcoind/keys/demo_privkey.txt`
@ -14,3 +15,6 @@ while sleep 10; do \
bitcoin-cli -datadir=/bitcoind generatetoaddress 1 $address; \
echo "Balance:" `bitcoin-cli -datadir=/bitcoind getbalance`; \
done
# If loop is interrupted, stop bitcoind
bitcoin-cli -datadir=/bitcoind stop
Loading…
Cancel
Save