Skip to content

Commit 0c80d8a

Browse files
committed
Update Dockerfile for Bitcoin Core Build
- Change base image from debian:bullseye-slim to debian:bookworm-slim. - Introduce BITCOIN_VERSION as an ARG for flexible version specification. - Update build steps to use CMake instead of autotools, reflecting changes in the Bitcoin build process. - Install additional dependencies: cmake and libsqlite3-dev during the build stage. - Modify final image dependencies to use libssl3 and add libevent-extra-2.1-7. - Correct paths for bitcoind and bitcoin-cli to reflect the new CMake build structure. - Create a non-root 'bitcoin' user for running the container, improving security. - Set the user to 'bitcoin' for container runtime. - Keep volumes and work directory setup for Bitcoin data and configurations. Signed-off-by: Artem Barger <artem@bargr.net>
1 parent 725c64f commit 0c80d8a

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

Dockerfile

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Stage 1: Build bitcoin core
2-
FROM debian:bullseye-slim AS builder
2+
FROM debian:bookworm-slim AS builder
3+
4+
ARG BITCOIN_VERSION=v29.0
35

46
RUN apt-get update && apt-get install -y \
57
automake \
8+
cmake \
69
autotools-dev \
710
build-essential \
811
git \
@@ -19,41 +22,49 @@ RUN apt-get update && apt-get install -y \
1922
libevent-dev \
2023
libdb++-dev \
2124
bsdmainutils \
25+
libsqlite3-dev \
2226
&& rm -rf /var/lib/apt/lists/*
2327

2428
WORKDIR /bitcoin
2529
RUN git clone https://github.com/bitcoin/bitcoin.git . \
26-
&& git checkout v25.1 \
27-
&& ./autogen.sh \
28-
&& ./configure --disable-wallet --without-gui --without-miniupnpc \
29-
&& make -j$(nproc) \
30-
&& strip src/bitcoin-cli
30+
&& git checkout -b ${BITCOIN_VERSION} ${BITCOIN_VERSION} \
31+
&& cmake -B build \
32+
&& cmake --build build -j$(nproc)
3133

3234
# Stage 2: Final image
33-
FROM debian:bullseye-slim
35+
FROM debian:bookworm-slim
3436

3537
RUN apt-get update && apt-get install -y \
3638
libboost-system1.74.0 \
3739
libboost-filesystem1.74.0 \
3840
libboost-chrono1.74.0 \
3941
libboost-program-options1.74.0 \
4042
libboost-thread1.74.0 \
41-
libssl1.1 \
43+
libssl3 \
4244
libevent-2.1-7 \
45+
libevent-extra-2.1-7 \
4346
libevent-pthreads-2.1-7 \
4447
iproute2 \
4548
iptables \
49+
libsqlite3-0 \
4650
&& rm -rf /var/lib/apt/lists/*
4751

48-
COPY --from=builder /bitcoin/src/bitcoind /usr/local/bin/
49-
COPY --from=builder /bitcoin/src/bitcoin-cli /usr/local/bin/
52+
COPY --from=builder /bitcoin/build/bin/bitcoind /usr/local/bin/
53+
COPY --from=builder /bitcoin/build/bin/bitcoin-cli /usr/local/bin/
5054

5155
RUN mkdir -p /bitcoin
5256

57+
# Create bitcoin user and group
58+
RUN groupadd -r bitcoin && \
59+
useradd -r -g bitcoin -s /sbin/nologin -c "Bitcoin node user" bitcoin && \
60+
chown -R bitcoin:bitcoin /bitcoin
61+
5362
VOLUME ["/bitcoin"]
5463
WORKDIR /bitcoin
5564

5665
# Expose RPC ports
5766
EXPOSE 8332 8333
5867

68+
USER bitcoin
69+
5970
ENTRYPOINT ["bitcoind", "-datadir=/bitcoin/.bitcoin", "-conf=/bitcoin/bitcoin.conf", "-rpcbind=0.0.0.0", "-daemon=0"]

0 commit comments

Comments
 (0)