Skip to content

Commit 725762d

Browse files
committed
Add bitcoin core 26.1
1 parent c3984aa commit 725762d

File tree

4 files changed

+265
-0
lines changed

4 files changed

+265
-0
lines changed

26/Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM debian:bookworm-slim as builder
2+
3+
LABEL maintainer.0="João Fonseca (@joaopaulofonseca)" \
4+
maintainer.1="Pedro Branco (@pedrobranco)" \
5+
maintainer.2="Rui Marinho (@ruimarinho)"
6+
7+
RUN apt-get update -y \
8+
&& apt-get install -y ca-certificates curl git gnupg gosu python3 wget --no-install-recommends \
9+
&& apt-get clean \
10+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
11+
12+
ARG TARGETPLATFORM
13+
ENV BITCOIN_VERSION=26.1
14+
ENV SIGS_REPO_URL="https://github.com/bitcoin-core/guix.sigs.git"
15+
ENV SIGS_CLONE_DIR="guix.sigs"
16+
ENV VERIFY_SCRIPT_URL="https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/verify-binaries/verify.py"
17+
ENV TMPDIR="/tmp/bitcoin_verify_binaries"
18+
19+
RUN set -ex \
20+
&& if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then export TARGETPLATFORM=x86_64-linux-gnu; fi \
21+
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then export TARGETPLATFORM=aarch64-linux-gnu; fi \
22+
&& if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then export TARGETPLATFORM=arm-linux-gnueabihf; fi \
23+
&& git clone ${SIGS_REPO_URL} ${SIGS_CLONE_DIR} \
24+
&& gpg --import "${SIGS_CLONE_DIR}"/builder-keys/* \
25+
&& curl -o verify.py ${VERIFY_SCRIPT_URL} \
26+
&& chmod +x verify.py \
27+
&& ./verify.py \
28+
--min-good-sigs 6 pub "${BITCOIN_VERSION}-linux" \
29+
&& tar -xzf "${TMPDIR}.${BITCOIN_VERSION}-linux/bitcoin-${BITCOIN_VERSION}-${TARGETPLATFORM}.tar.gz" -C /opt \
30+
&& rm -rf ${SIGS_CLONE_DIR} \
31+
&& rm -rf ${TMPDIR} \
32+
&& rm -rf /opt/bitcoin-${BITCOIN_VERSION}/bin/bitcoin-qt
33+
34+
# Second stage
35+
FROM debian:bookworm-slim
36+
37+
ARG UID=101
38+
ARG GID=101
39+
40+
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
41+
ENV BITCOIN_VERSION=26.1
42+
ENV PATH=/opt/bitcoin-${BITCOIN_VERSION}/bin:$PATH
43+
44+
RUN groupadd --gid ${GID} bitcoin \
45+
&& useradd --create-home --no-log-init -u ${UID} -g ${GID} bitcoin \
46+
&& apt-get update -y \
47+
&& apt-get install -y gosu --no-install-recommends \
48+
&& apt-get clean \
49+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
50+
51+
COPY --from=builder /opt/bitcoin-${BITCOIN_VERSION} /opt/bitcoin-${BITCOIN_VERSION}
52+
53+
COPY docker-entrypoint.sh /entrypoint.sh
54+
55+
VOLUME ["/home/bitcoin/.bitcoin"]
56+
EXPOSE 8332 8333 18332 18333 18443 18444 38333 38332
57+
58+
ENTRYPOINT ["/entrypoint.sh"]
59+
RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"
60+
CMD ["bitcoind"]

26/alpine/Dockerfile

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Build stage for BerkeleyDB
2+
FROM alpine as berkeleydb
3+
4+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
5+
RUN apk --no-cache add autoconf
6+
RUN apk --no-cache add automake
7+
RUN apk --no-cache add build-base
8+
RUN apk --no-cache add libressl
9+
10+
ENV BERKELEYDB_VERSION=db-4.8.30.NC
11+
ENV BERKELEYDB_PREFIX=/opt/${BERKELEYDB_VERSION}
12+
13+
RUN wget https://download.oracle.com/berkeley-db/${BERKELEYDB_VERSION}.tar.gz
14+
RUN tar -xzf *.tar.gz
15+
RUN sed s/__atomic_compare_exchange/__atomic_compare_exchange_db/g -i ${BERKELEYDB_VERSION}/dbinc/atomic.h
16+
RUN mkdir -p ${BERKELEYDB_PREFIX}
17+
18+
WORKDIR /${BERKELEYDB_VERSION}/build_unix
19+
20+
RUN ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=${BERKELEYDB_PREFIX} --build=aarch64-unknown-linux-gnu
21+
RUN make -j4
22+
RUN make install
23+
RUN rm -rf ${BERKELEYDB_PREFIX}/docs
24+
25+
# Build stage for Bitcoin Core
26+
FROM alpine as bitcoin-core
27+
28+
COPY --from=berkeleydb /opt /opt
29+
30+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
31+
RUN apk --no-cache add autoconf
32+
RUN apk --no-cache add automake
33+
RUN apk --no-cache add boost-dev
34+
RUN apk --no-cache add build-base
35+
RUN apk --no-cache add chrpath
36+
RUN apk --no-cache add file
37+
RUN apk --no-cache add gnupg
38+
RUN apk --no-cache add git
39+
RUN apk --no-cache add libevent-dev
40+
RUN apk --no-cache add libressl
41+
RUN apk --no-cache add libtool
42+
RUN apk --no-cache add linux-headers
43+
RUN apk --no-cache add sqlite-dev
44+
RUN apk --no-cache add zeromq-dev
45+
46+
ENV BITCOIN_VERSION=26.1
47+
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
48+
ENV BITCOIN_SOURCE_DIR=/bitcoin/src
49+
ENV SIGS_REPO_URL="https://github.com/bitcoin-core/guix.sigs.git"
50+
ENV SIGS_CLONE_DIR="guix.sigs"
51+
ENV VERIFY_SCRIPT_URL="https://github.com/bitcoin/bitcoin/raw/master/contrib/verify-binaries/verify.py"
52+
53+
WORKDIR /bitcoin
54+
RUN set -ex \
55+
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}.tar.gz \
56+
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS \
57+
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc \
58+
&& git clone ${SIGS_REPO_URL} ${SIGS_CLONE_DIR} \
59+
&& gpg --import "${SIGS_CLONE_DIR}"/builder-keys/* \
60+
&& wget -O verify.py ${VERIFY_SCRIPT_URL} \
61+
&& chmod +x verify.py \
62+
&& ./verify.py bin SHA256SUMS \
63+
"bitcoin-${BITCOIN_VERSION}.tar.gz" \
64+
&& mkdir -p ${BITCOIN_SOURCE_DIR} \
65+
&& tar -xzf "bitcoin-${BITCOIN_VERSION}.tar.gz" -C ${BITCOIN_SOURCE_DIR} \
66+
&& rm -rf ${SIGS_CLONE_DIR}
67+
68+
WORKDIR "${BITCOIN_SOURCE_DIR}/bitcoin-${BITCOIN_VERSION}"
69+
70+
RUN sed -i s:sys/fcntl.h:fcntl.h: src/compat/compat.h
71+
RUN ./autogen.sh
72+
RUN ./configure LDFLAGS=-L`ls -d /opt/db*`/lib/ CPPFLAGS=-I`ls -d /opt/db*`/include/ \
73+
--prefix=${BITCOIN_PREFIX} \
74+
--mandir=/usr/share/man \
75+
--disable-tests \
76+
--disable-bench \
77+
--disable-ccache \
78+
--with-gui=no \
79+
--with-utils \
80+
--with-libs \
81+
--with-sqlite=yes \
82+
--with-daemon
83+
RUN make -j4
84+
RUN make install
85+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-cli
86+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-tx
87+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoind
88+
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a
89+
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0
90+
91+
# Build stage for compiled artifacts
92+
FROM alpine
93+
94+
ARG UID=100
95+
ARG GID=101
96+
97+
LABEL maintainer.0="João Fonseca (@joaopaulofonseca)" \
98+
maintainer.1="Pedro Branco (@pedrobranco)" \
99+
maintainer.2="Rui Marinho (@ruimarinho)"
100+
101+
RUN addgroup bitcoin --gid ${GID} --system
102+
RUN adduser --uid ${UID} --system bitcoin --ingroup bitcoin
103+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
104+
RUN apk --no-cache add \
105+
libevent \
106+
libzmq \
107+
shadow \
108+
sqlite-dev \
109+
su-exec
110+
111+
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
112+
ENV BITCOIN_VERSION=26.1
113+
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
114+
ENV PATH=${BITCOIN_PREFIX}/bin:$PATH
115+
116+
COPY --from=bitcoin-core /opt /opt
117+
COPY docker-entrypoint.sh /entrypoint.sh
118+
119+
VOLUME ["/home/bitcoin/.bitcoin"]
120+
121+
EXPOSE 8332 8333 18332 18333 18444
122+
123+
ENTRYPOINT ["/entrypoint.sh"]
124+
125+
RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"
126+
127+
CMD ["bitcoind"]

26/alpine/docker-entrypoint.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ -n "${UID+x}" ] && [ "${UID}" != "0" ]; then
5+
usermod -u "$UID" bitcoin
6+
fi
7+
8+
if [ -n "${GID+x}" ] && [ "${GID}" != "0" ]; then
9+
groupmod -g "$GID" bitcoin
10+
fi
11+
12+
echo "$0: assuming uid:gid for bitcoin:bitcoin of $(id -u bitcoin):$(id -g bitcoin)"
13+
14+
if [ $(echo "$1" | cut -c1) = "-" ]; then
15+
echo "$0: assuming arguments for bitcoind"
16+
17+
set -- bitcoind "$@"
18+
fi
19+
20+
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "bitcoind" ]; then
21+
mkdir -p "$BITCOIN_DATA"
22+
chmod 700 "$BITCOIN_DATA"
23+
# Fix permissions for home dir.
24+
chown -R bitcoin:bitcoin "$(getent passwd bitcoin | cut -d: -f6)"
25+
# Fix permissions for bitcoin data dir.
26+
chown -R bitcoin:bitcoin "$BITCOIN_DATA"
27+
28+
echo "$0: setting data directory to $BITCOIN_DATA"
29+
30+
set -- "$@" -datadir="$BITCOIN_DATA"
31+
fi
32+
33+
if [ "$1" = "bitcoind" ] || [ "$1" = "bitcoin-cli" ] || [ "$1" = "bitcoin-tx" ]; then
34+
echo
35+
exec su-exec bitcoin "$@"
36+
fi
37+
38+
echo
39+
exec "$@"

26/docker-entrypoint.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ -n "${UID+x}" ] && [ "${UID}" != "0" ]; then
5+
usermod -u "$UID" bitcoin
6+
fi
7+
8+
if [ -n "${GID+x}" ] && [ "${GID}" != "0" ]; then
9+
groupmod -g "$GID" bitcoin
10+
fi
11+
12+
echo "$0: assuming uid:gid for bitcoin:bitcoin of $(id -u bitcoin):$(id -g bitcoin)"
13+
14+
if [ $(echo "$1" | cut -c1) = "-" ]; then
15+
echo "$0: assuming arguments for bitcoind"
16+
17+
set -- bitcoind "$@"
18+
fi
19+
20+
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "bitcoind" ]; then
21+
mkdir -p "$BITCOIN_DATA"
22+
chmod 700 "$BITCOIN_DATA"
23+
# Fix permissions for home dir.
24+
chown -R bitcoin:bitcoin "$(getent passwd bitcoin | cut -d: -f6)"
25+
# Fix permissions for bitcoin data dir.
26+
chown -R bitcoin:bitcoin "$BITCOIN_DATA"
27+
28+
echo "$0: setting data directory to $BITCOIN_DATA"
29+
30+
set -- "$@" -datadir="$BITCOIN_DATA"
31+
fi
32+
33+
if [ "$1" = "bitcoind" ] || [ "$1" = "bitcoin-cli" ] || [ "$1" = "bitcoin-tx" ]; then
34+
echo
35+
exec gosu bitcoin "$@"
36+
fi
37+
38+
echo
39+
exec "$@"

0 commit comments

Comments
 (0)