Skip to content

Commit d68afa5

Browse files
committed
strip and compress binaries
1 parent 450af5f commit d68afa5

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

autotools/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ RUN apk add --no-cache \
3838
git \
3939
libtool \
4040
linux-headers \
41-
pkgconf
41+
pkgconf \
42+
upx
4243

4344
RUN tar zxf bitcoin-${KNOTS_VERSION}.tar.gz
4445

4546
RUN ./bitcoin-${KNOTS_VERSION}/autogen.sh
4647

4748
RUN make -C bitcoin-${KNOTS_VERSION}/depends -j$(nproc) NO_QT=1 NO_NATPMP=1 NO_UPNP=1 NO_USDT=1
4849

49-
ENV CFLAGS="-O2 --static -static -fPIC"
50-
ENV CXXFLAGS="-O2 --static -static -fPIC"
51-
ENV LDFLAGS="-s -static-libgcc -static-libstdc++"
50+
ENV CFLAGS="-g0 -Os --static -static -fPIC"
51+
ENV CXXFLAGS="-g0 -Os --static -static -fPIC"
52+
ENV LDFLAGS="-Wl,--strip-all -static-libgcc -static-libstdc++"
5253

5354
RUN CONFIG_SITE=$(find /tmp/bitcoin-${KNOTS_VERSION}/depends | grep -E "config\.site$") \
5455
&& mkdir build \
@@ -76,12 +77,14 @@ RUN make -C ./build -j$(nproc)
7677

7778
RUN make -C ./build install
7879

80+
RUN upx --lzma /usr/local/bin/*
7981

8082
FROM alpine:3.23 AS final
8183

8284
COPY --from=builder /usr/local/bin/* /usr/local/bin/
8385

8486
RUN apk add --no-cache \
87+
libgcc \
8588
libstdc++ \
8689
tor \
8790
&& adduser -D bitcoin \

cmake/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,16 @@ RUN apk add --no-cache \
6060
cmake \
6161
curl \
6262
linux-headers \
63-
pkgconf
63+
pkgconf \
64+
upx
6465

6566
RUN tar zxf bitcoin-${KNOTS_VERSION}.tar.gz
6667

6768
RUN make -C bitcoin-${KNOTS_VERSION}/depends -j$(nproc) NO_QT=1 NO_NATPMP=1 NO_UPNP=1 NO_USDT=1
6869

6970
RUN cmake -S bitcoin-${KNOTS_VERSION} -B build \
71+
-DAPPEND_CPPFLAGS=-g0 \
72+
-DAPPEND_LDFLAGS=-Wl,--strip-all \
7073
-DBUILD_SHARED_LIBS=OFF \
7174
-DBUILD_TESTS=OFF \
7275
-DBUILD_TX=ON \
@@ -75,6 +78,8 @@ RUN cmake -S bitcoin-${KNOTS_VERSION} -B build \
7578
-DCMAKE_BUILD_TYPE=MinSizeRel \
7679
-DINSTALL_MAN=OFF \
7780
-DREDUCE_EXPORTS=ON \
81+
-DSECP256K1_APPEND_CFLAGS=-g0 \
82+
-DSECP256K1_APPEND_LDFLAGS=-Wl,--strip-all \
7883
-DWITH_BDB=ON \
7984
-DWITH_ZMQ=ON \
8085
--toolchain $(find /tmp/bitcoin-${KNOTS_VERSION}/depends | grep -E "toolchain\.cmake$")
@@ -83,12 +88,14 @@ RUN cmake --build build -j $(nproc)
8388

8489
RUN cmake --install build
8590

91+
RUN upx --lzma /usr/local/bin/*
8692

8793
FROM alpine:3.23 AS final
8894

8995
COPY --from=builder /usr/local/bin/* /usr/local/bin/
9096

9197
RUN apk add --no-cache \
98+
libgcc \
9299
libstdc++ \
93100
tor \
94101
&& adduser -D bitcoin \

0 commit comments

Comments
 (0)