Skip to content

Commit 1beffd2

Browse files
authored
Merge pull request #91 from lncm/26-0
26 0 version of bitcoin
2 parents 9c74cfb + e9d678a commit 1beffd2

File tree

3 files changed

+471
-2
lines changed

3 files changed

+471
-2
lines changed

.github/workflows/test.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
subver:
21-
- '22.0'
22-
- '23.0'
2321
- '24.0'
2422
- '25.0'
23+
- '26.0'
2524

2625
arch:
2726
- amd64

25.1/Dockerfile

+235
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# This Dockerfile builds Bitcoin Core and packages it into a minimal `final` image
2+
3+
# VERSION of Bitcoin Core to be build
4+
# NOTE: Unlike our other images this one is NOT prefixed with `v`,
5+
# as many things (like download URLs) use this form instead.
6+
ARG VERSION=25.1
7+
8+
# CPU architecture to build binaries for
9+
ARG ARCH
10+
11+
# Define default versions so that they don't have to be repeated throughout the file
12+
ARG VER_ALPINE=3.18
13+
14+
# $USER name, and data $DIR to be used in the `final` image
15+
ARG USER=bitcoind
16+
ARG DIR=/data
17+
18+
# Choose where to get bitcoind sources from, options: release, git
19+
# NOTE: Only `SOURCE=git` can be used for RC releases
20+
ARG SOURCE=release
21+
22+
# Choose where to get BerkeleyDB from, options: prebuilt, compile
23+
# NOTE: When compiled here total execution time exceeds allowed CI limits, so pre-built one is used by default
24+
ARG BDB_SOURCE=prebuilt
25+
26+
27+
28+
#
29+
## `preparer-base` installs dependencies needed by both ways of fetching the source,
30+
# as well as imports GPG keys needed to verify authenticity of the source.
31+
#
32+
FROM alpine:${VER_ALPINE} AS preparer-base
33+
34+
RUN apk add --no-cache gnupg
35+
36+
# Guix Builder Keys: https://github.com/bitcoin-core/guix.sigs/tree/main/builder-keys
37+
# curl -s "https://api.github.com/repos/bitcoin-core/guix.sigs/contents/builder-keys" | jq -r '.[].download_url'
38+
ENV KEYS 982A193E3CE0EED535E09023188CBB2648416AD5 101598DC823C1B5F9A6624ABA5E0907A0380E6C3 9EDAFF80E080659604F4A76B2EBB056FD847F8A7 \
39+
ED9BDF7AD6A55E232E84524257FF9BDBCC301009 A8FC55F3B04BA3146F3492E79303B33A305224CB 152812300785C96444D3334D17565732E08E5E41 \
40+
0AD83877C1F0CD1EE9BD660AD7CC770B81FD22A8 C060A6635913D98A3587D7DB1C2491FFEB0EF770 590B7292695AFFA5B672CBB2E13FC145CD3F4304 \
41+
948444FCE03B05BA5AB0591EC37B1C1D44C786EE E777299FC265DD04793070EB944D35F9AC3DB76A 6B002C6EA3F91B1B0DF0C9BC8F617F1200A6D25C \
42+
F4FC70F07310028424EFC20A8E4256593F177720 D1DBF2C4B96F2DEBF4C16654410108112E7EA81F 287AE4CA1187C68C08B49CB2D11BD4F33F1DB499 \
43+
616516B8EB6ED02882FC4A7A8ADCB558C4F33D65 71A3B16735405025D447E8F274810B012346C9A6 2F78ACF677029767C8736F13747A7AE2FB0FD25B \
44+
133EAC179436F14A5CF1B794860FEB804E669320 9ED99C7A355AE46098103E74476E74C8529A9006 6A8F9C266528E25AEB1D7731C2371D91CB716EA7 \
45+
28E72909F1717FE9607754F8A7BEB2621678D37D 67AA5B46E7AF78053167FE343B8F814A784218F8 79D00BAC68B56D422F945A8F8E3A8F3247DBCBBF \
46+
C388F6961FB972A95678E327F62711DBDCA8AE56
47+
48+
RUN gpg --keyserver keyserver.ubuntu.com --recv-keys $KEYS
49+
50+
#
51+
## Option #1: [default] Fetch bitcoind source from release tarballs
52+
#
53+
FROM preparer-base AS preparer-release
54+
55+
ARG VERSION
56+
57+
# Download sigs
58+
ADD https://bitcoincore.org/bin/bitcoin-core-$VERSION/SHA256SUMS.asc ./
59+
# Download checksums
60+
ADD https://bitcoincore.org/bin/bitcoin-core-$VERSION/SHA256SUMS ./
61+
62+
# Download source code (intentionally different website than checksums)
63+
ADD https://github.com/bitcoin/bitcoin/archive/refs/tags/v$VERSION.tar.gz ./bitcoin-$VERSION.tar.gz
64+
65+
# Verify that hashes are signed with the previously imported key
66+
RUN gpg --verify SHA256SUMS.asc SHA256SUMS
67+
68+
# Verify that downloaded source-code archive matches exactly the hash that's provided
69+
RUN grep "bitcoin-$VERSION.tar.gz" SHA256SUMS | sha256sum -c
70+
71+
# Extract
72+
RUN tar -xzf "bitcoin-$VERSION.tar.gz" && \
73+
rm -f "bitcoin-$VERSION.tar.gz"
74+
75+
#
76+
## Option #2: Fetch bitcoind source from GitHub
77+
#
78+
FROM preparer-base AS preparer-git
79+
80+
ARG VERSION
81+
82+
RUN apk add --no-cache git
83+
84+
# Fetch the source code at a specific TAG
85+
RUN git clone -b "v$VERSION" --depth=1 https://github.com/bitcoin/bitcoin.git "/bitcoin-$VERSION/"
86+
87+
# Verify tag, and copy source code to predetermined location on success
88+
RUN cd "/bitcoin-$VERSION/" && \
89+
git verify-tag "v$VERSION"
90+
91+
92+
93+
#
94+
## Alias to go around `COPY` not accepting ARGs in value passed to `--from=`
95+
#
96+
FROM preparer-${SOURCE} AS preparer
97+
98+
99+
100+
#
101+
## `berkeleydb-prebuilt` downloads a pre-built BerkeleyDB to make sure
102+
# the overall build time of this Dockerfile fits within CI limits.
103+
#
104+
FROM lncm/berkeleydb:v4.8.30.NC${ARCH:+-${ARCH}} AS berkeleydb-prebuilt
105+
106+
#
107+
## `berkeleydb-compile` builds BerkeleyDB from source using script provided in bitcoind repo.
108+
#
109+
FROM alpine:${VER_ALPINE} AS berkeleydb-compile
110+
# TODO: implement ^^
111+
RUN echo "Not implemented" && exit 1
112+
113+
114+
FROM berkeleydb-${BDB_SOURCE} AS berkeleydb
115+
116+
117+
118+
#
119+
## `builder` builds Bitcoin Core regardless on how the source, and BDB code were obtained.
120+
#
121+
# NOTE: this stage is emulated using QEMU
122+
# NOTE: `${ARCH:+${ARCH}/}` - if ARCH is set, append `/` to it, leave it empty otherwise
123+
FROM ${ARCH:+${ARCH}/}alpine:${VER_ALPINE} AS builder
124+
125+
ARG VERSION
126+
ARG SOURCE
127+
128+
RUN apk add --no-cache \
129+
autoconf \
130+
automake \
131+
boost-dev \
132+
sqlite-dev \
133+
build-base \
134+
chrpath \
135+
file \
136+
libevent-dev \
137+
libressl \
138+
libtool \
139+
linux-headers \
140+
zeromq-dev
141+
142+
# Fetch pre-built berkeleydb
143+
COPY --from=berkeleydb /opt/ /opt/
144+
145+
# Change to the extracted directory
146+
WORKDIR /bitcoin-$VERSION/
147+
148+
# Copy bitcoin source (downloaded & verified in previous stages)
149+
COPY --from=preparer /bitcoin-$VERSION/ ./
150+
151+
ENV BITCOIN_PREFIX /opt/bitcoin-$VERSION
152+
153+
RUN ./autogen.sh
154+
155+
# TODO: Try to optimize on passed params
156+
RUN ./configure LDFLAGS=-L/opt/db4/lib/ CPPFLAGS=-I/opt/db4/include/ \
157+
CXXFLAGS="-O2" \
158+
--prefix="$BITCOIN_PREFIX" \
159+
--disable-man \
160+
--disable-shared \
161+
--disable-ccache \
162+
--disable-tests \
163+
--enable-static \
164+
--enable-reduce-exports \
165+
--without-gui \
166+
--without-libs \
167+
--with-utils \
168+
--with-sqlite=yes \
169+
--with-daemon
170+
171+
RUN make -j$(( $(nproc) + 1 ))
172+
RUN make install
173+
174+
# List installed binaries pre-strip & strip them
175+
RUN ls -lh "$BITCOIN_PREFIX/bin/"
176+
RUN strip -v "$BITCOIN_PREFIX/bin/bitcoin"*
177+
178+
# List installed binaries post-strip & print their checksums
179+
RUN ls -lh "$BITCOIN_PREFIX/bin/"
180+
RUN sha256sum "$BITCOIN_PREFIX/bin/bitcoin"*
181+
182+
183+
184+
#
185+
## `final` aggregates build results from previous stages into a necessary minimum
186+
# ready to be used, and published to Docker Hub.
187+
#
188+
# NOTE: this stage is emulated using QEMU
189+
# NOTE: `${ARCH:+${ARCH}/}` - if ARCH is set, append `/` to it, leave it empty otherwise
190+
FROM ${ARCH:+${ARCH}/}alpine:${VER_ALPINE} AS final
191+
192+
ARG VERSION
193+
ARG USER
194+
ARG DIR
195+
196+
LABEL maintainer="Damian Mee (@meeDamian)"
197+
198+
RUN apk add --no-cache \
199+
libevent \
200+
libsodium \
201+
libstdc++ \
202+
libzmq \
203+
sqlite-libs
204+
205+
COPY --from=builder /opt/bitcoin-$VERSION/bin/bitcoin* /usr/local/bin/
206+
207+
# NOTE: Default GID == UID == 1000
208+
RUN adduser --disabled-password \
209+
--home "$DIR/" \
210+
--gecos "" \
211+
"$USER"
212+
213+
USER $USER
214+
215+
# Prevents `VOLUME $DIR/.bitcoind/` being created as owned by `root`
216+
RUN mkdir -p "$DIR/.bitcoin/"
217+
218+
# Expose volume containing all `bitcoind` data
219+
VOLUME $DIR/.bitcoin/
220+
221+
# REST interface
222+
EXPOSE 8080
223+
224+
# P2P network (mainnet, testnet & regnet respectively)
225+
EXPOSE 8333 18333 18444
226+
227+
# RPC interface (mainnet, testnet & regnet respectively)
228+
EXPOSE 8332 18332 18443
229+
230+
# ZMQ ports (for transactions & blocks respectively)
231+
EXPOSE 28332 28333
232+
233+
ENTRYPOINT ["bitcoind"]
234+
235+
CMD ["-zmqpubrawblock=tcp://0.0.0.0:28332", "-zmqpubrawtx=tcp://0.0.0.0:28333"]

0 commit comments

Comments
 (0)