Skip to content

Instantly share code, notes, and snippets.

@Raimo33
Last active December 13, 2025 16:55
Show Gist options
  • Select an option

  • Save Raimo33/4de6298007cf6f3982b6d341abc316d8 to your computer and use it in GitHub Desktop.

Select an option

Save Raimo33/4de6298007cf6f3982b6d341abc316d8 to your computer and use it in GitHub Desktop.
Bitcoin IBD run
FROM debian:trixie-slim AS builder
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
cmake \
ninja-build \
libboost-system-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libevent-dev \
libcapnp-dev \
capnproto
WORKDIR /opt/bitcoin
COPY . .
RUN rm -rf build
WORKDIR /opt/bitcoin/build
RUN cmake .. -G Ninja \
-DCMAKE_INSTALL_PREFIX="/usr/local/" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DAEMON=ON \
-DBUILD_TESTS=ON \
-DENABLE_IPC=ON \
-DBUILD_BITCOIN_BIN=OFF \
-DBUILD_GUI=OFF \
-DBUILD_CLI=OFF \
-DBUILD_TX=OFF \
-DBUILD_UTIL=OFF \
-DBUILD_WALLET_TOOL=OFF \
-DBUILD_UTIL_CHAINSTATE=OFF \
-DBUILD_KERNEL_LIB=OFF \
-DBUILD_BENCH=OFF \
-DBUILD_FUZZ_BINARY=OFF \
-DENABLE_WALLET=OFF \
-DENABLE_EXTERNAL_SIGNER=OFF \
-DWITH_ZMQ=OFF \
-DWITH_USDT=OFF \
-DINSTALL_MAN=OFF \
-DWITH_CCACHE=OFF
RUN cmake --build .
RUN ctest --output-on-failure
RUN cmake --install .
RUN strip --strip-unneeded /usr/local/bin/bitcoind
FROM debian:trixie-slim AS final
RUN apt-get update && apt-get install -y \
libboost-system1.88.0 \
libboost-filesystem1.88.0 \
libboost-program-options1.88.0 \
libevent-core-2.1-7 \
libevent-extra-2.1-7 \
libevent-pthreads-2.1-7 \
libcapnp-1.1.0 \
python3-pip \
hyperfine && \
rm -rf /var/lib/apt/lists/*
RUN pip install --break-system-packages pyperf
COPY --from=builder /usr/local/bin/bitcoind /usr/local/bin/bitcoind
WORKDIR /var/lib/bitcoin
# ------- IBD --------
# CMD ["hyperfine", \
# "--runs", "3", \
# "--setup", "pyperf system tune; bitcoind -datadir=. -stopatheight=1 || true", \
# "--prepare", "rm -rf blocks/ chainstate/", \
# "--cleanup", "pyperf system reset", \
# "bitcoind -datadir=. -listen=0 -dnsseed=0 -fixedseeds=0 -printtoconsole=0 -blocksonly=1 -stopatheight=900000 -dbcache=4096 -par=4"]
# ------- REINDEX --------
CMD ["hyperfine", \
"--runs", "3", \
"--setup", "pyperf system tune; bitcoind -datadir=. -stopatheight=1 || true", \
"--prepare", "rm -rf chainstate/", \
"--cleanup", "pyperf system reset", \
"bitcoind -datadir=. -listen=0 -dnsseed=0 -fixedseeds=0 -printtoconsole=0 -blocksonly=1 -reindex -stopatheight=900000 -dbcache=4096 -par=4"]
@Raimo33
Copy link
Author

Raimo33 commented Dec 12, 2025

to build:

docker build -f /path/to/Dockerfile -t btcibd /path/to/repo; beep

to run:

docker run --rm -it --init --privileged -v /path/to/data:/var/lib/bitcoin btcibd; beep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment