Add Bitcoin Core 31.0
This commit is contained in:
parent
11428fe3eb
commit
d0534b03b8
90
Bitcoin/31.0/docker-entrypoint.sh
Executable file
90
Bitcoin/31.0/docker-entrypoint.sh
Executable file
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
is_sqlite()
|
||||
{
|
||||
local f=$1
|
||||
# read first 16 bytes and compare to the SQLite header
|
||||
printf 'SQLite format 3\0' | cmp -n 16 -s - "$f"
|
||||
}
|
||||
|
||||
if [[ "$1" == "bitcoin-cli" || "$1" == "bitcoin-tx" || "$1" == "bitcoind" || "$1" == "test_bitcoin" ]]; then
|
||||
mkdir -p "$BITCOIN_DATA"
|
||||
|
||||
CONFIG_PREFIX=""
|
||||
if [[ "${BITCOIN_NETWORK}" == "regtest" ]]; then
|
||||
CONFIG_PREFIX=$'regtest=1\n[regtest]'
|
||||
elif [[ "${BITCOIN_NETWORK}" == "testnet" ]]; then
|
||||
CONFIG_PREFIX=$'testnet=1\n[test]'
|
||||
elif [[ "${BITCOIN_NETWORK}" == "mainnet" ]]; then
|
||||
CONFIG_PREFIX=$'[main]'
|
||||
elif [[ "${BITCOIN_NETWORK}" == "signet" ]]; then
|
||||
CONFIG_PREFIX=$'signet=1\n[signet]'
|
||||
else
|
||||
BITCOIN_NETWORK="mainnet"
|
||||
CONFIG_PREFIX=$'[main]'
|
||||
fi
|
||||
|
||||
need_migrate=false
|
||||
if [[ "$BITCOIN_WALLETDIR" ]] && [[ "$BITCOIN_NETWORK" ]]; then
|
||||
NL=$'\n'
|
||||
WALLETDIR="$BITCOIN_WALLETDIR/${BITCOIN_NETWORK}"
|
||||
WALLETFILE="${WALLETDIR}/wallet.dat"
|
||||
mkdir -p "$WALLETDIR"
|
||||
chown -R bitcoin:bitcoin "$WALLETDIR"
|
||||
CONFIG_PREFIX="${CONFIG_PREFIX}${NL}walletdir=${WALLETDIR}${NL}"
|
||||
: "${CREATE_WALLET:=true}"
|
||||
if [[ "${CREATE_WALLET}" != "false" ]]; then
|
||||
if ! [[ -f "${WALLETFILE}" ]]; then
|
||||
echo "The wallet does not exists, creating it at ${WALLETDIR}..."
|
||||
gosu bitcoin bitcoin-wallet "-${BITCOIN_NETWORK}" "-datadir=${WALLETDIR}" "-wallet=" create
|
||||
elif ! is_sqlite "${WALLETFILE}"; then
|
||||
need_migrate=true
|
||||
echo "Legacy wallet migration needed"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cat <<-EOF > "$BITCOIN_DATA/bitcoin.conf"
|
||||
${CONFIG_PREFIX}
|
||||
printtoconsole=1
|
||||
rpcallowip=::/0
|
||||
${BITCOIN_EXTRA_ARGS}
|
||||
EOF
|
||||
chown bitcoin:bitcoin "$BITCOIN_DATA/bitcoin.conf"
|
||||
|
||||
if [[ "${BITCOIN_TORCONTROL}" ]]; then
|
||||
# Because bitcoind only accept torcontrol= host as an ip only, we resolve it here and add to config
|
||||
TOR_CONTROL_HOST=$(echo ${BITCOIN_TORCONTROL} | cut -d ':' -f 1)
|
||||
TOR_CONTROL_PORT=$(echo ${BITCOIN_TORCONTROL} | cut -d ':' -f 2)
|
||||
if [[ "$TOR_CONTROL_HOST" ]] && [[ "$TOR_CONTROL_PORT" ]]; then
|
||||
TOR_IP=$(getent hosts $TOR_CONTROL_HOST | cut -d ' ' -f 1)
|
||||
echo "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" >> "$BITCOIN_DATA/bitcoin.conf"
|
||||
echo "Added "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" to $BITCOIN_DATA/bitcoin.conf"
|
||||
else
|
||||
echo "Invalid BITCOIN_TORCONTROL"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ensure correct ownership and linking of data directory
|
||||
# we do not update group ownership here, in case users want to mount
|
||||
# a host directory and still retain access to it
|
||||
chown -R bitcoin "$BITCOIN_DATA"
|
||||
ln -sfn "$BITCOIN_DATA" /home/bitcoin/.bitcoin
|
||||
chown -h bitcoin:bitcoin /home/bitcoin/.bitcoin
|
||||
rm -f /home/bitcoin/.bitcoin/settings.json
|
||||
|
||||
if [[ "${need_migrate}" == "true" ]]; then
|
||||
echo "Migrating legacy bitcoin wallet..."
|
||||
gosu bitcoin "$@" &
|
||||
BITCOIN_PID=$!
|
||||
gosu bitcoin bitcoin-cli -datadir="${BITCOIN_DATA}" -rpcwait migratewallet ""
|
||||
gosu bitcoin bitcoin-cli -datadir="${BITCOIN_DATA}" -rpcwait stop
|
||||
wait "${BITCOIN_PID}"
|
||||
echo "Bitcoin legacy wallet migrated."
|
||||
fi
|
||||
|
||||
exec gosu bitcoin "$@"
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
46
Bitcoin/31.0/linuxamd64.Dockerfile
Normal file
46
Bitcoin/31.0/linuxamd64.Dockerfile
Normal file
@ -0,0 +1,46 @@
|
||||
FROM debian:bookworm-slim as builder
|
||||
|
||||
RUN set -ex \
|
||||
&& apt-get update \
|
||||
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget
|
||||
|
||||
ENV BITCOIN_VERSION 31.0
|
||||
ENV BITCOIN_URL https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
|
||||
ENV BITCOIN_SHA256 d3e4c58a35b1d0a97a457462c94f55501ad167c660c245cb1ffa565641c65074
|
||||
|
||||
# install bitcoin binaries
|
||||
RUN set -ex \
|
||||
&& cd /tmp \
|
||||
&& wget -qO bitcoin.tar.gz "$BITCOIN_URL" \
|
||||
&& echo "$BITCOIN_SHA256 bitcoin.tar.gz" | sha256sum -c - \
|
||||
&& mkdir bin \
|
||||
&& tar -xzvf bitcoin.tar.gz -C /tmp/bin --strip-components=2 "bitcoin-$BITCOIN_VERSION/bin/bitcoin-cli" "bitcoin-$BITCOIN_VERSION/bin/bitcoind" "bitcoin-$BITCOIN_VERSION/bin/bitcoin-wallet" \
|
||||
&& cd bin \
|
||||
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.16/gosu-amd64" \
|
||||
&& echo "3a4e1fc7430f9e7dd7b0cbbe0bfde26bf4a250702e84cf48a1eb2b631c64cf13 gosu" | sha256sum -c -
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
COPY --from=builder "/tmp/bin" /usr/local/bin
|
||||
|
||||
ARG BITCOIN_USER_ID=999
|
||||
ARG BITCOIN_GROUP_ID=999
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -qq --no-install-recommends xxd && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN chmod +x /usr/local/bin/gosu && groupadd -r -g $BITCOIN_GROUP_ID bitcoin && useradd -r -m -u $BITCOIN_USER_ID -g bitcoin bitcoin
|
||||
|
||||
# create data directory
|
||||
ENV BITCOIN_DATA /data
|
||||
RUN mkdir "$BITCOIN_DATA" \
|
||||
&& chown -R bitcoin:bitcoin "$BITCOIN_DATA" \
|
||||
&& ln -sfn "$BITCOIN_DATA" /home/bitcoin/.bitcoin \
|
||||
&& chown -h bitcoin:bitcoin /home/bitcoin/.bitcoin
|
||||
|
||||
VOLUME /data
|
||||
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 8332 8333 18332 18333 18443 18444
|
||||
CMD ["bitcoind"]
|
||||
51
Bitcoin/31.0/linuxarm32v7.Dockerfile
Normal file
51
Bitcoin/31.0/linuxarm32v7.Dockerfile
Normal file
@ -0,0 +1,51 @@
|
||||
# Use manifest image which support all architecture
|
||||
FROM debian:bookworm-slim as builder
|
||||
|
||||
RUN set -ex \
|
||||
&& apt-get update \
|
||||
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget
|
||||
RUN apt-get install -qq --no-install-recommends qemu-user-static binfmt-support
|
||||
|
||||
ENV BITCOIN_VERSION 31.0
|
||||
ENV BITCOIN_URL https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-arm-linux-gnueabihf.tar.gz
|
||||
ENV BITCOIN_SHA256 8c19d007bfc73502625095ea4073af3a98ceb722d500556ab173bac5bcadd0d6
|
||||
|
||||
# install bitcoin binaries
|
||||
RUN set -ex \
|
||||
&& cd /tmp \
|
||||
&& wget -qO bitcoin.tar.gz "$BITCOIN_URL" \
|
||||
&& echo "$BITCOIN_SHA256 bitcoin.tar.gz" | sha256sum -c - \
|
||||
&& mkdir bin \
|
||||
&& tar -xzvf bitcoin.tar.gz -C /tmp/bin --strip-components=2 "bitcoin-$BITCOIN_VERSION/bin/bitcoin-cli" "bitcoin-$BITCOIN_VERSION/bin/bitcoind" "bitcoin-$BITCOIN_VERSION/bin/bitcoin-wallet" \
|
||||
&& cd bin \
|
||||
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.16/gosu-armhf" \
|
||||
&& echo "1b670d5426e1ddbb14a14280afb6850a48c219189d4cfe7e6eb2cc08a4fc7785 gosu" | sha256sum -c -
|
||||
|
||||
# Making sure the builder build an arm image despite being x64
|
||||
FROM --platform=arm debian:bookworm-slim
|
||||
|
||||
COPY --from=builder "/tmp/bin" /usr/local/bin
|
||||
COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static
|
||||
|
||||
ARG BITCOIN_USER_ID=999
|
||||
ARG BITCOIN_GROUP_ID=999
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -qq --no-install-recommends xxd && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN chmod +x /usr/local/bin/gosu && groupadd -r -g $BITCOIN_GROUP_ID bitcoin && useradd -r -m -u $BITCOIN_USER_ID -g bitcoin bitcoin
|
||||
|
||||
# create data directory
|
||||
ENV BITCOIN_DATA /data
|
||||
RUN mkdir "$BITCOIN_DATA" \
|
||||
&& chown -R bitcoin:bitcoin "$BITCOIN_DATA" \
|
||||
&& ln -sfn "$BITCOIN_DATA" /home/bitcoin/.bitcoin \
|
||||
&& chown -h bitcoin:bitcoin /home/bitcoin/.bitcoin
|
||||
|
||||
VOLUME /data
|
||||
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 8332 8333 18332 18333 18443 18444
|
||||
CMD ["bitcoind"]
|
||||
51
Bitcoin/31.0/linuxarm64v8.Dockerfile
Normal file
51
Bitcoin/31.0/linuxarm64v8.Dockerfile
Normal file
@ -0,0 +1,51 @@
|
||||
# Use manifest image which support all architecture
|
||||
FROM debian:bookworm-slim as builder
|
||||
|
||||
RUN set -ex \
|
||||
&& apt-get update \
|
||||
&& apt-get install -qq --no-install-recommends ca-certificates dirmngr gosu wget
|
||||
RUN apt-get install -qq --no-install-recommends qemu-user-static binfmt-support
|
||||
|
||||
ENV BITCOIN_VERSION 31.0
|
||||
ENV BITCOIN_URL https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-aarch64-linux-gnu.tar.gz
|
||||
ENV BITCOIN_SHA256 4de1d568dedd48604f75132421bc0abeca432639589b49a3909c81db3a813112
|
||||
|
||||
# install bitcoin binaries
|
||||
RUN set -ex \
|
||||
&& cd /tmp \
|
||||
&& wget -qO bitcoin.tar.gz "$BITCOIN_URL" \
|
||||
&& echo "$BITCOIN_SHA256 bitcoin.tar.gz" | sha256sum -c - \
|
||||
&& mkdir bin \
|
||||
&& tar -xzvf bitcoin.tar.gz -C /tmp/bin --strip-components=2 "bitcoin-$BITCOIN_VERSION/bin/bitcoin-cli" "bitcoin-$BITCOIN_VERSION/bin/bitcoind" "bitcoin-$BITCOIN_VERSION/bin/bitcoin-wallet" \
|
||||
&& cd bin \
|
||||
&& wget -qO gosu "https://github.com/tianon/gosu/releases/download/1.16/gosu-arm64" \
|
||||
&& echo "23fa49907d5246d2e257de3bf883f57fba47fe1f559f7e732ff16c0f23d2b6a6 gosu" | sha256sum -c -
|
||||
|
||||
# Making sure the builder build an arm image despite being x64
|
||||
FROM --platform=arm64 debian:bookworm-slim
|
||||
|
||||
COPY --from=builder "/tmp/bin" /usr/local/bin
|
||||
COPY --from=builder /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static
|
||||
|
||||
ARG BITCOIN_USER_ID=999
|
||||
ARG BITCOIN_GROUP_ID=999
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -qq --no-install-recommends xxd && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN chmod +x /usr/local/bin/gosu && groupadd -r -g $BITCOIN_GROUP_ID bitcoin && useradd -r -m -u $BITCOIN_USER_ID -g bitcoin bitcoin
|
||||
|
||||
# create data directory
|
||||
ENV BITCOIN_DATA /data
|
||||
RUN mkdir "$BITCOIN_DATA" \
|
||||
&& chown -R bitcoin:bitcoin "$BITCOIN_DATA" \
|
||||
&& ln -sfn "$BITCOIN_DATA" /home/bitcoin/.bitcoin \
|
||||
&& chown -h bitcoin:bitcoin /home/bitcoin/.bitcoin
|
||||
|
||||
VOLUME /data
|
||||
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 8332 8333 18332 18333 18443 18444
|
||||
CMD ["bitcoind"]
|
||||
Loading…
Reference in New Issue
Block a user