Skip to content

Commit d828baa

Browse files
Switch Bitcoin image to rootless and distroless (#13)
1 parent a6be58d commit d828baa

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

images/bitcoind/Dockerfile

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1.3-labs
2-
FROM ubuntu:22.04 as build
2+
FROM debian:12@sha256:b6507e340c43553136f5078284c8c68d86ec8262b1724dde73c325e8d3dcdeba as build
33

44
ARG VERSION=v29.0
55

@@ -12,48 +12,32 @@ RUN <<-EOF
1212
git \
1313
build-essential \
1414
cmake \
15-
pkgconf \
16-
python3 \
17-
libevent-dev \
18-
libboost-dev \
19-
libzmq3-dev
15+
curl
2016
EOF
2117

2218
RUN git clone --single-branch --branch "${VERSION}" https://github.com/bitcoin/bitcoin.git /opt/bitcoin
2319

2420
WORKDIR /opt/bitcoin
2521

2622
RUN <<-EOF
27-
cmake -B build -DENABLE_WALLET=OFF -DWITH_ZMQ=ON
28-
cmake --build build -j 4
29-
cmake --install build
23+
make -C depends/ -j $(getconf _NPROCESSORS_ONLN) NO_QT=1 NO_QR=1 NO_WALLET=1
24+
cmake -B build \
25+
--toolchain /opt/bitcoin/depends/x86_64-pc-linux-gnu/toolchain.cmake \
26+
-DCMAKE_INSTALL_PREFIX=/opt/bitcoin/build/
27+
cmake --build build -j $(getconf _NPROCESSORS_ONLN)
28+
cmake --install build
29+
find /opt/bitcoin/build/bin -type f -executable -exec strip -s {} + 2>/dev/null || true
3030
EOF
3131

32-
FROM ubuntu:22.04
32+
RUN mkdir -p /opt/bitcoin/.bitcoin/db && \
33+
chown -R 65532:65532 /opt/bitcoin/
3334

34-
ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London"
35+
FROM gcr.io/distroless/cc-debian12:nonroot@sha256:d1b8e4c52be1111aa108e959ef2a822299bb70fd1819dd250871a2601ca1e4b6 as final
3536

36-
RUN <<-EOF
37-
apt-get -y update && \
38-
apt-get -y install \
39-
libevent-dev \
40-
libboost-system-dev \
41-
libboost-filesystem-dev \
42-
libboost-chrono-dev \
43-
libboost-test-dev \
44-
libboost-thread-dev \
45-
libzmq3-dev \
46-
net-tools \
47-
curl \
48-
jq \
49-
netcat
50-
EOF
51-
52-
RUN groupadd --gid "10001" "bitcoin" && \
53-
useradd --uid "10001" --gid "10001" --shell /bin/bash --create-home "bitcoin" && \
54-
mkdir -p /opt/bitcoin/.bitcoin/db && \
55-
chown -R bitcoin:bitcoin /opt/bitcoin/
37+
ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London"
5638

57-
COPY --from=build /usr/local/bin /usr/local/bin
39+
COPY --from=build /opt/bitcoin/build/bin /opt/bitcoin/bin
40+
COPY --from=build /opt/bitcoin/.bitcoin/db /opt/bitcoin/.bitcoin/db
41+
COPY bitcoin.conf /opt/bitcoin/.bitcoin/bitcoin.conf
5842

59-
ENTRYPOINT ["bitcoind", "-conf=/opt/bitcoin/.bitcoin/bitcoin.conf", "-datadir=/opt/bitcoin/.bitcoin/db", "-txindex=1"]
43+
ENTRYPOINT ["/opt/bitcoin/bin/bitcoind", "-conf=/opt/bitcoin/.bitcoin/bitcoin.conf", "-datadir=/opt/bitcoin/.bitcoin/db", "-txindex=1"]

images/bitcoind/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
docker build -t flarefoundation/bitcoin:28.1 .
1+
docker build -t flarefoundation/bitcoin:29.0 .

0 commit comments

Comments
 (0)