.dockerignore excludes .git, so util/genbuild.sh finds no repository inside the container and emits "// No build information available", which clientversion.cpp renders as the "-unk" suffix. Every binary produced by ./build.sh --linux-compat therefore self-reports "v1.2.0-unk" and cannot be traced to a commit -- including release artifacts, since this build path is part of the v1.2.0 tag. Pre-generating src/obj/build.h does not survive (genbuild rewrites it when the content differs), and simply un-ignoring .git does not help a linked worktree, whose .git is a file pointing outside the build context. So build.sh computes the version on the host, mirroring genbuild.sh rule for rule -- the nearest tag only when HEAD is that tag and the tree is clean, otherwise v<VERSION>-<short sha> with a -dirty suffix -- and passes it through a BUILD_DESC build-arg that Dockerfile.compat exports as DRAGONX_BUILD_DESC. genbuild.sh honours that variable when set and is otherwise untouched; with git metadata present it emits a byte-identical build.h. Every added git call is guarded with || true because build.sh runs under set -eu -o pipefail: a source tarball, a host without git, or a branch whose only reachable tags are lightweight (v1.0.1-v1.0.3 are lightweight; v1.1.0 is the first annotated one) would otherwise abort the build with no diagnostic. Those cases now degrade to the previous "-unk" behaviour with a warning. A direct "docker build -f Dockerfile.compat" passes no BUILD_DESC and still produces -unk; the Dockerfile now says so loudly rather than silently.
47 lines
1.9 KiB
Docker
47 lines
1.9 KiB
Docker
# Base image is parameterised so one Dockerfile can produce binaries for several
|
|
# glibc floors: docker build --build-arg BASE_IMAGE=ubuntu:18.04 ...
|
|
# The default is unchanged, so `./build.sh --linux-compat` behaves exactly as before.
|
|
ARG BASE_IMAGE=ubuntu:20.04
|
|
FROM ${BASE_IMAGE}
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool \
|
|
ncurses-dev unzip python3 zlib1g-dev wget bsdmainutils automake cmake \
|
|
libcurl4-openssl-dev curl git binutils \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /build
|
|
COPY . /build/
|
|
|
|
# Clean host-built depends and src artifacts to force full rebuild inside container
|
|
RUN rm -rf /build/depends/built /build/depends/work \
|
|
/build/depends/x86_64-unknown-linux-gnu \
|
|
/build/depends/x86_64-w64-mingw32 \
|
|
/build/src/RandomX/build \
|
|
&& find /build/src -name '*.o' -o -name '*.a' -o -name '*.la' -o -name '*.lo' \
|
|
-o -name '*.lai' | xargs rm -f \
|
|
&& rm -rf /build/src/univalue/.libs /build/src/univalue/.deps \
|
|
&& rm -rf /build/src/.libs /build/src/.deps \
|
|
&& rm -rf /build/src/cc/*.o /build/src/cc/*.a \
|
|
&& rm -f /build/config.status /build/config.log
|
|
|
|
# The build context excludes .git (see .dockerignore), so genbuild.sh cannot derive
|
|
# a version and would stamp the binaries "-unk". build.sh computes the real one
|
|
# on the host and passes it in here.
|
|
ARG BUILD_DESC=
|
|
ENV DRAGONX_BUILD_DESC=${BUILD_DESC}
|
|
|
|
RUN if [ -z "$DRAGONX_BUILD_DESC" ]; then \
|
|
echo "WARNING: no BUILD_DESC build-arg -- binaries will be stamped -unk." >&2; \
|
|
echo " Prefer ./build.sh --linux-compat, or pass --build-arg BUILD_DESC=..." >&2; \
|
|
fi
|
|
|
|
RUN cd /build && ./util/build.sh --disable-tests -j$(nproc)
|
|
|
|
# Strip binaries inside the container so extracted files are already small
|
|
RUN strip /build/src/dragonxd /build/src/dragonx-cli /build/src/dragonx-tx
|
|
|
|
CMD ["/bin/bash"]
|