Skip to content

Commit

Permalink
build: add GIT_VERSION to track build
Browse files Browse the repository at this point in the history
build policy container with `--build-arg GIT_VERSION=$(git rev-parse --short=8 HEAD 2>/dev/null)`

Signed-off-by: l1b0k <[email protected]>
  • Loading branch information
l1b0k committed Jan 22, 2024
1 parent 3a329ef commit 5a8cb1e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Dockerfile.policy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM --platform=$TARGETPLATFORM calico/go-build:v0.90 as felix-builder
ARG GOPROXY
ARG GIT_VERSION
ENV GOPROXY $GOPROXY
ENV GIT_BRANCH=v3.24.5
ENV GIT_COMMIT=f1a1611acb98d9187f48bbbe2227301aa69f0499
Expand All @@ -13,15 +14,16 @@ RUN cd /go/src/github.com/projectcalico/calico && \
CGO_ENABLED=0 go build -o bin/calico-felix -ldflags \
"-s -w -X github.com/projectcalico/calico/felix/buildinfo.GitVersion=${GIT_BRANCH} \
-X github.com/projectcalico/calico/felix/buildinfo.BuildDate=$(date -u +'%FT%T%z') \
-X github.com/projectcalico/calico/felix/buildinfo.GitRevision=${GIT_COMMIT} \
-B 0x${GIT_COMMIT}" "github.com/projectcalico/calico/felix/cmd/calico-felix" && \
-X github.com/projectcalico/calico/felix/buildinfo.GitRevision=${GIT_VERSION} \
-B 0x${GIT_VERSION}" "github.com/projectcalico/calico/felix/cmd/calico-felix" && \
( ! $(readelf -d bin/calico-felix | grep -q NEEDED) || ( echo "Error: bin/calico-felix was not statically linked"; false )) \
&& chmod +x /go/src/github.com/projectcalico/calico/bin/calico-felix

FROM --platform=$TARGETPLATFORM quay.io/cilium/cilium-builder:1d3ec0f0b74a32048a9716c7a8ce1eee851ca0ec@sha256:9fab9eb021456705d99b014d2f9e59aff9f50aa1a296aa55e984f3e947a62120 as cilium-builder
ARG GOPROXY
ENV GOPROXY $GOPROXY
ARG CILIUM_SHA=""
ARG GIT_VERSION=""
LABEL cilium-sha=${CILIUM_SHA}
LABEL maintainer="[email protected]"
WORKDIR /go/src/github.com/cilium
Expand All @@ -41,7 +43,7 @@ ARG LIBNETWORK_PLUGIN
# Please do not add any dependency updates before the 'make install' here,
# as that will mess with caching for incremental builds!
#
RUN cd cilium && make NOSTRIP=$NOSTRIP LOCKDEBUG=$LOCKDEBUG PKG_BUILD=1 V=$V LIBNETWORK_PLUGIN=$LIBNETWORK_PLUGIN \
RUN cd cilium && make NOSTRIP=$NOSTRIP LOCKDEBUG=$LOCKDEBUG PKG_BUILD=1 GIT_VERSION=${GIT_VERSION} V=$V LIBNETWORK_PLUGIN=$LIBNETWORK_PLUGIN \
SKIP_DOCS=true DESTDIR=/tmp/install clean-container build-container install-container
RUN cp /tmp/install/opt/cni/bin/cilium-cni /tmp/install/usr/bin/

Expand Down

0 comments on commit 5a8cb1e

Please sign in to comment.