Skip to content

Instantly share code, notes, and snippets.

@1ma
Created March 6, 2025 14:22
Show Gist options
  • Save 1ma/3458fba0c182408d009134d774c2d4b3 to your computer and use it in GitHub Desktop.
Save 1ma/3458fba0c182408d009134d774c2d4b3 to your computer and use it in GitHub Desktop.
Bitcoin Core CMake Edition
FROM alpine:3.21 AS builder
WORKDIR /tmp
RUN apk add --no-cache \
git \
&& git clone https://github.com/bitcoin/bitcoin
WORKDIR /tmp/bitcoin
RUN apk add --no-cache \
bash \
build-base \
cmake \
curl \
linux-headers \
pkgconf \
python3
RUN make -C depends -j$(nproc) NO_QT=1 NO_NATPMP=1 NO_UPNP=1 NO_USDT=1
RUN cmake -B build \
-DBUILD_TESTS=OFF \
-DBUILD_TX=ON \
-DBUILD_UTIL=ON \
-DBUILD_WALLET_TOOL=ON \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DINSTALL_MAN=OFF \
-DWITH_BDB=ON \
-DWITH_ZMQ=ON \
--toolchain depends/x86_64-pc-linux-musl/toolchain.cmake
RUN cmake --build build -j 8
RUN cmake --install build
FROM alpine:3.21 AS final
COPY --from=builder /usr/local/bin/* /usr/local/bin/
COPY --from=builder /tmp/bitcoin/test/functional/test_framework /opt/bitcoin/test/functional/test_framework
COPY --from=builder /tmp/bitcoin/contrib/signet/miner /opt/bitcoin/contrib/signet/miner
RUN apk add --no-cache \
python3 \
tor \
&& adduser -D bitcoin \
&& mkdir /home/bitcoin/.bitcoin \
&& chown bitcoin:bitcoin /home/bitcoin/.bitcoin \
&& ln -s /opt/bitcoin/contrib/signet/miner /usr/local/bin/miner
USER bitcoin
VOLUME ["/home/bitcoin/.bitcoin"]
# REST interface
EXPOSE 8080
# P2P network (mainnet, testnet, regtest & signet respectively)
EXPOSE 8333 18333 18444 38333
# RPC interface (mainnet, testnet, regtest & signet respectively)
EXPOSE 8332 18332 18443 38332
# ZMQ ports (for block hashes, raw blocks & raw transactions respectively)
EXPOSE 8443 28332 28333
ENTRYPOINT ["/usr/local/bin/bitcoind", "-nodebuglogfile", "-zmqpubhashblock=tcp://0.0.0.0:8443", "-zmqpubrawblock=tcp://0.0.0.0:28332", "-zmqpubrawtx=tcp://0.0.0.0:28333"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment