Skip to content

Commit 771d9b3

Browse files
Silvengaruimarinho
authored andcommitted
1 parent 2da9cc9 commit 771d9b3

File tree

6 files changed

+261
-4
lines changed

6 files changed

+261
-4
lines changed

.github/workflows/build.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
strategy:
99
matrix:
1010
version:
11+
- '22'
12+
- '22/alpine'
1113
- '0.21'
1214
- '0.21/alpine'
1315
- '0.20'
@@ -40,7 +42,7 @@ jobs:
4042
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
4143
4244
BITCOIN_VERSION=${{matrix.version}}
43-
LATEST_BITCOIN_MAJOR_VERSION=$(ls | grep 0 | sort -n | tail -n 1)
45+
LATEST_BITCOIN_MAJOR_VERSION=$(find . -type d -maxdepth 1 -not -path '*/\.*' | sort -n | tail -n 1 | cut -c 3-)
4446
PLATFORMS="linux/amd64"
4547
PUSH=false
4648
REPO=ruimarinho/bitcoin-core
@@ -56,7 +58,11 @@ jobs:
5658
TAGS+=("$REPO:$TAG")
5759
fi
5860
59-
TAG_MAJOR_MINOR=$(echo $TAG | cut -c -4)
61+
if [ $(version ${TAG}) -ge $(version "22.0") ]; then
62+
TAG_MAJOR_MINOR=$(echo $TAG | cut -c -2)"
63+
else
64+
TAG_MAJOR_MINOR=$(echo $TAG | cut -c -4)"
65+
fi
6066
6167
if [ $(version ${TAG_MAJOR_MINOR}) -ne $(version ${BITCOIN_VERSION}) ]; then
6268
echo "Skipping build of base image $BITCOIN_VERSION/ as ${TAG} is targeted at ${TAG_MAJOR_MINOR}/"

22/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM debian:bullseye-slim
2+
3+
LABEL maintainer.0="João Fonseca (@joaopaulofonseca)" \
4+
maintainer.1="Pedro Branco (@pedrobranco)" \
5+
maintainer.2="Rui Marinho (@ruimarinho)"
6+
7+
RUN useradd -r bitcoin \
8+
&& apt-get update -y \
9+
&& apt-get install -y curl gnupg gosu \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
12+
13+
ARG TARGETPLATFORM
14+
ENV BITCOIN_VERSION=22.0
15+
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
16+
ENV PATH=/opt/bitcoin-${BITCOIN_VERSION}/bin:$PATH
17+
18+
RUN set -ex \
19+
&& if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then export TARGETPLATFORM=x86_64-linux-gnu; fi \
20+
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then export TARGETPLATFORM=aarch64-linux-gnu; fi \
21+
&& if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then export TARGETPLATFORM=arm-linux-gnueabihf; fi \
22+
&& for key in \
23+
0CCBAAFD76A2ECE2CCD3141DE2FFD5B1D88CA97D \
24+
152812300785C96444D3334D17565732E08E5E41 \
25+
0AD83877C1F0CD1EE9BD660AD7CC770B81FD22A8 \
26+
590B7292695AFFA5B672CBB2E13FC145CD3F4304 \
27+
28F5900B1BB5D1A4B6B6D1A9ED357015286A333D \
28+
637DB1E23370F84AFF88CCE03152347D07DA627C \
29+
CFB16E21C950F67FA95E558F2EEB9F5CC09526C1 \
30+
6E01EEC9656903B0542B8F1003DB6322267C373B \
31+
D1DBF2C4B96F2DEBF4C16654410108112E7EA81F \
32+
82921A4B88FD454B7EB8CE3C796C4109063D4EAF \
33+
9DEAE0DC7063249FB05474681E4AED62986CD25D \
34+
9D3CC86A72F8494342EA5FD10A41BDC3F4FAFF1C \
35+
74E2DEF5D77260B98BC19438099BAD163C70FBFA \
36+
; do \
37+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" || \
38+
gpg --batch --keyserver keys.openpgp.org --recv-keys "$key" || \
39+
gpg --batch --keyserver pgp.mit.edu --recv-keys "$key" || \
40+
gpg --batch --keyserver keyserver.pgp.com --recv-keys "$key" || \
41+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
42+
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
43+
done \
44+
&& curl -SLO https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-${TARGETPLATFORM}.tar.gz \
45+
&& curl -SLO https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS \
46+
&& curl -SLO https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc \
47+
&& gpg --verify SHA256SUMS.asc SHA256SUMS \
48+
&& grep " bitcoin-${BITCOIN_VERSION}-${TARGETPLATFORM}.tar.gz" SHA256SUMS | sha256sum -c - \
49+
&& tar -xzf *.tar.gz -C /opt \
50+
&& rm *.tar.gz *.asc \
51+
&& rm -rf /opt/bitcoin-${BITCOIN_VERSION}/bin/bitcoin-qt
52+
53+
COPY docker-entrypoint.sh /entrypoint.sh
54+
55+
VOLUME ["/home/bitcoin/.bitcoin"]
56+
57+
EXPOSE 8332 8333 18332 18333 18443 18444 38333 38332
58+
59+
ENTRYPOINT ["/entrypoint.sh"]
60+
61+
RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"
62+
63+
CMD ["bitcoind"]

22/alpine/Dockerfile

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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}
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 libevent-dev
39+
RUN apk --no-cache add libressl
40+
RUN apk --no-cache add libtool
41+
RUN apk --no-cache add linux-headers
42+
RUN apk --no-cache add zeromq-dev
43+
RUN set -ex \
44+
&& for key in \
45+
0CCBAAFD76A2ECE2CCD3141DE2FFD5B1D88CA97D \
46+
152812300785C96444D3334D17565732E08E5E41 \
47+
0AD83877C1F0CD1EE9BD660AD7CC770B81FD22A8 \
48+
590B7292695AFFA5B672CBB2E13FC145CD3F4304 \
49+
28F5900B1BB5D1A4B6B6D1A9ED357015286A333D \
50+
637DB1E23370F84AFF88CCE03152347D07DA627C \
51+
CFB16E21C950F67FA95E558F2EEB9F5CC09526C1 \
52+
6E01EEC9656903B0542B8F1003DB6322267C373B \
53+
D1DBF2C4B96F2DEBF4C16654410108112E7EA81F \
54+
82921A4B88FD454B7EB8CE3C796C4109063D4EAF \
55+
9DEAE0DC7063249FB05474681E4AED62986CD25D \
56+
9D3CC86A72F8494342EA5FD10A41BDC3F4FAFF1C \
57+
74E2DEF5D77260B98BC19438099BAD163C70FBFA \
58+
; do \
59+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" || \
60+
gpg --batch --keyserver keys.openpgp.org --recv-keys "$key" || \
61+
gpg --batch --keyserver keyserver.pgp.com --recv-keys "$key" || \
62+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
63+
gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" ; \
64+
done
65+
66+
ENV BITCOIN_VERSION=22.0
67+
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
68+
69+
RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS
70+
RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc
71+
RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}.tar.gz
72+
RUN gpg --verify SHA256SUMS.asc SHA256SUMS
73+
RUN grep " bitcoin-${BITCOIN_VERSION}.tar.gz\$" SHA256SUMS | sha256sum -c -
74+
RUN tar -xzf *.tar.gz
75+
76+
WORKDIR /bitcoin-${BITCOIN_VERSION}
77+
78+
RUN sed -i '/AC_PREREQ/a\AR_FLAGS=cr' src/univalue/configure.ac
79+
RUN sed -i '/AX_PROG_CC_FOR_BUILD/a\AR_FLAGS=cr' src/secp256k1/configure.ac
80+
RUN sed -i s:sys/fcntl.h:fcntl.h: src/compat.h
81+
RUN ./autogen.sh
82+
RUN ./configure LDFLAGS=-L`ls -d /opt/db*`/lib/ CPPFLAGS=-I`ls -d /opt/db*`/include/ \
83+
--prefix=${BITCOIN_PREFIX} \
84+
--mandir=/usr/share/man \
85+
--disable-tests \
86+
--disable-bench \
87+
--disable-ccache \
88+
--with-gui=no \
89+
--with-utils \
90+
--with-libs \
91+
--with-daemon
92+
RUN make -j4
93+
RUN make install
94+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-cli
95+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoin-tx
96+
RUN strip ${BITCOIN_PREFIX}/bin/bitcoind
97+
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a
98+
RUN strip ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0
99+
100+
# Build stage for compiled artifacts
101+
FROM alpine
102+
103+
LABEL maintainer.0="João Fonseca (@joaopaulofonseca)" \
104+
maintainer.1="Pedro Branco (@pedrobranco)" \
105+
maintainer.2="Rui Marinho (@ruimarinho)"
106+
107+
RUN adduser -S bitcoin
108+
RUN sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories
109+
RUN apk --no-cache add \
110+
boost-filesystem \
111+
boost-system \
112+
boost-thread \
113+
libevent \
114+
libzmq \
115+
su-exec
116+
117+
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
118+
ENV BITCOIN_VERSION=22.0
119+
ENV BITCOIN_PREFIX=/opt/bitcoin-${BITCOIN_VERSION}
120+
ENV PATH=${BITCOIN_PREFIX}/bin:$PATH
121+
122+
COPY --from=bitcoin-core /opt /opt
123+
COPY docker-entrypoint.sh /entrypoint.sh
124+
125+
VOLUME ["/home/bitcoin/.bitcoin"]
126+
127+
EXPOSE 8332 8333 18332 18333 18444
128+
129+
ENTRYPOINT ["/entrypoint.sh"]
130+
131+
RUN bitcoind -version | grep "Bitcoin Core version v${BITCOIN_VERSION}"
132+
133+
CMD ["bitcoind"]

22/alpine/docker-entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ $(echo "$1" | cut -c1) = "-" ]; then
5+
echo "$0: assuming arguments for bitcoind"
6+
7+
set -- bitcoind "$@"
8+
fi
9+
10+
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "bitcoind" ]; then
11+
mkdir -p "$BITCOIN_DATA"
12+
chmod 700 "$BITCOIN_DATA"
13+
chown -R bitcoin "$BITCOIN_DATA"
14+
15+
echo "$0: setting data directory to $BITCOIN_DATA"
16+
17+
set -- "$@" -datadir="$BITCOIN_DATA"
18+
fi
19+
20+
if [ "$1" = "bitcoind" ] || [ "$1" = "bitcoin-cli" ] || [ "$1" = "bitcoin-tx" ]; then
21+
echo
22+
exec su-exec bitcoin "$@"
23+
fi
24+
25+
echo
26+
exec "$@"

22/docker-entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ $(echo "$1" | cut -c1) = "-" ]; then
5+
echo "$0: assuming arguments for bitcoind"
6+
7+
set -- bitcoind "$@"
8+
fi
9+
10+
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "bitcoind" ]; then
11+
mkdir -p "$BITCOIN_DATA"
12+
chmod 700 "$BITCOIN_DATA"
13+
chown -R bitcoin "$BITCOIN_DATA"
14+
15+
echo "$0: setting data directory to $BITCOIN_DATA"
16+
17+
set -- "$@" -datadir="$BITCOIN_DATA"
18+
fi
19+
20+
if [ "$1" = "bitcoind" ] || [ "$1" = "bitcoin-cli" ] || [ "$1" = "bitcoin-tx" ]; then
21+
echo
22+
exec gosu bitcoin "$@"
23+
fi
24+
25+
echo
26+
exec "$@"

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ A bitcoin-core docker image with support for the following platforms:
1010

1111
## Tags
1212

13-
- `0.21.1`, `0.21`, `latest` ([0.21/Dockerfile](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/0.21/Dockerfile)) [**multi-arch**]
13+
- `22.0`, `22`, `latest` ([22.0/Dockerfile](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/22.0/Dockerfile)) [**multi-arch**]
14+
- `22.0-alpine`, `22.0-alpine` ([22.0/alpine/Dockerfile](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/22.0/alpine/Dockerfile))
15+
16+
- `0.21.1`, `0.21` ([0.21/Dockerfile](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/0.21/Dockerfile)) [**multi-arch**]
1417
- `0.21.1-alpine`, `0.21-alpine` ([0.21/alpine/Dockerfile](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/0.21/alpine/Dockerfile))
1518

1619
- `0.20.1`, `0.20` ([0.20/Dockerfile](https://github.com/ruimarinho/docker-bitcoin-core/blob/master/0.20/Dockerfile)) [**multi-arch**]
@@ -229,7 +232,7 @@ curl --data-binary '{"jsonrpc":"1.0","id":"1","method":"getnetworkinfo","params"
229232

230233
#### Signet
231234

232-
- JSON-RPC/REST: 38332
235+
- JSON-RPC/REST: 38332
233236
- P2P: 38333
234237

235238
## Archived tags

0 commit comments

Comments
 (0)