Closed zw963 closed 8 months ago
When you override the LDFLAGS when calling make you need to preserve the original LDFLAGS from the makefile.
Try make LDFLAGS="-lbz2 -static"
When you override the LDFLAGS when calling make you need to preserve the original LDFLAGS from the makefile. Try
make LDFLAGS="-lbz2 -static"
It works! thank you.
╰─ $ ldd bsdiff bspatch
bsdiff:
not a dynamic executable
bspatch:
not a dynamic executable
I you can provide a precompiled static binary in the released page with a tag (as most of command tools create by golang, rust packages does), would be very grateful, because compile dynamic, often result in running bspatch failed on remote VPS (because those machine system is older).
Following is the dockerfile for build above static bianry:
# -*- mode: dockerfile-ts; -*-
# 确保 build 和 linking 是同一个 alpine 版本
ARG alpine_version=3.19
# mirrors.ustc.edu.cn mirrors.tuna.tsinghua.edu.cn
ARG alpine_mirror=mirrors.ustc.edu.cn
# ============================== 使用目标系统架构 link binary ==============================
FROM alpine:$alpine_version as link_target
ARG alpine_mirror
RUN sed -i "s/dl-cdn.alpinelinux.org/$alpine_mirror/g" /etc/apk/repositories
# Add trusted CAs for communicating with external services and required build tooling
# 额外添加了 -dev 包,也允许编译动态版本。
# g++ 依赖 libc-dev, libc-dev 依赖 musl-dev, gcc
RUN set -eux; \
apk add \
--update \
gc-dev pcre2-dev \
libevent-dev libevent-static \
sqlite-static openssl-libs-static \
yaml-static \
zlib-dev zlib-static \
bzip2-dev bzip2-static \
g++ make automake libtool autoconf git \
;
RUN addgroup -g 1000 docker && \
adduser -u 1000 -G docker -h /home/docker -s /bin/sh -D docker
USER docker:docker
# WORKDIR 应该放在 USER 后面,因为如果 /app 不存在,需要创建这个文件夹
WORKDIR /app
COPY --chown=docker:docker . .
RUN make LDFLAGS="-lbz2 -static"
# Build a minimal docker image
FROM scratch AS mini
WORKDIR /
ENV PATH=$PATH:/
# These provide certificate chain validation where communicating with external services over TLS
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
# This is your application
COPY --from=link_target /app /
# COPY --from=build_cross_platform /app/openapi.yml /openapi.yml
USER docker:docker
# Spider-gazelle has a built in helper for health checks (change this as desired for your applications)
# HEALTHCHECK CMD ["/app", "-c", "http://127.0.0.1:3000/"]
# Run the app binding on port 3000
# EXPOSE 3000
ENTRYPOINT ["/app/bin/app"]
# CMD ["/app", "-b", "0.0.0.0", "-p", "3000"]
Then run with:
$: docker buildx build --progress=plain --platform linux/amd64 --target mini -t build_cross_link_binary --output type=local,dest=linux/amd64 -f $dockerfile .
It can build bsdiff for other platform, e.g. linux/arm64/v8
Thanks!
Hi, i try build bsdiff binary use
LDFLAGS=-static
in the alpine 3.19, but no luck.Do you consider support this? or may i do something wrong?
Thanks!