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.0
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.0
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" ]
0 commit comments