|
| 1 | +# Setup deps stage |
| 2 | +FROM alpine AS deps |
| 3 | +ARG REPO |
| 4 | +ARG COMMIT_SHA |
| 5 | +ARG BUILD_ARGS |
| 6 | + |
| 7 | +RUN --mount=type=cache,target=/var/cache/apk \ |
| 8 | + sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories \ |
| 9 | + && apk --no-cache add \ |
| 10 | + cmake \ |
| 11 | + python3 \ |
| 12 | + boost-dev \ |
| 13 | + build-base \ |
| 14 | + chrpath \ |
| 15 | + file \ |
| 16 | + gnupg \ |
| 17 | + git \ |
| 18 | + libevent-dev \ |
| 19 | + libressl \ |
| 20 | + libtool \ |
| 21 | + linux-headers \ |
| 22 | + sqlite-dev \ |
| 23 | + zeromq-dev |
| 24 | + |
| 25 | +COPY isroutable.patch /tmp/ |
| 26 | +COPY addrman.patch /tmp/ |
| 27 | + |
| 28 | + |
| 29 | +# Clone and patch and build stage |
| 30 | +FROM deps AS build |
| 31 | +ENV BITCOIN_PREFIX=/opt/bitcoin |
| 32 | +WORKDIR /build |
| 33 | + |
| 34 | +RUN set -ex \ |
| 35 | + && cd /build \ |
| 36 | + && git clone --depth 1 "https://github.com/${REPO}" \ |
| 37 | + && cd bitcoin \ |
| 38 | + && git fetch --depth 1 origin "$COMMIT_SHA" \ |
| 39 | + && git checkout "$COMMIT_SHA" \ |
| 40 | + && git apply /tmp/isroutable.patch \ |
| 41 | + && git apply /tmp/addrman.patch \ |
| 42 | + && sed -i s:sys/fcntl.h:fcntl.h: src/compat/compat.h \ |
| 43 | + && cmake -B build \ |
| 44 | + -DCMAKE_INSTALL_PREFIX=${BITCOIN_PREFIX} \ |
| 45 | + ${BUILD_ARGS} \ |
| 46 | + && cmake --build build -j$(nproc) \ |
| 47 | + && cmake --install build \ |
| 48 | + && strip ${BITCOIN_PREFIX}/bin/bitcoin-cli \ |
| 49 | + && strip ${BITCOIN_PREFIX}/bin/bitcoind \ |
| 50 | + && rm -f ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.a \ |
| 51 | + && rm -f ${BITCOIN_PREFIX}/lib/libbitcoinconsensus.so.0.0.0 |
| 52 | + |
| 53 | +# Final clean stage |
| 54 | +FROM alpine |
| 55 | +ARG UID=100 |
| 56 | +ARG GID=101 |
| 57 | +ENV BITCOIN_DATA=/root/.bitcoin |
| 58 | +ENV BITCOIN_PREFIX=/opt/bitcoin |
| 59 | +ENV PATH=${BITCOIN_PREFIX}/bin:$PATH |
| 60 | +LABEL maintainer.0="bitcoindevproject" |
| 61 | + |
| 62 | +RUN addgroup bitcoin --gid ${GID} --system \ |
| 63 | + && adduser --uid ${UID} --system bitcoin --ingroup bitcoin |
| 64 | +RUN --mount=type=cache,target=/var/cache/apk sed -i 's/http\:\/\/dl-cdn.alpinelinux.org/https\:\/\/alpine.global.ssl.fastly.net/g' /etc/apk/repositories \ |
| 65 | + && apk --no-cache add \ |
| 66 | + bash \ |
| 67 | + libevent \ |
| 68 | + libzmq \ |
| 69 | + shadow \ |
| 70 | + sqlite-dev \ |
| 71 | + su-exec |
| 72 | + |
| 73 | +COPY --from=build /opt/bitcoin /usr/local |
| 74 | +COPY entrypoint.sh / |
| 75 | + |
| 76 | +VOLUME ["/home/bitcoin/.bitcoin"] |
| 77 | +EXPOSE 8332 8333 18332 18333 18443 18444 38333 38332 |
| 78 | + |
| 79 | +ENTRYPOINT ["/entrypoint.sh"] |
| 80 | +CMD ["bitcoind"] |
0 commit comments