osbuild / bootc-image-builder

A container for deploying bootable container images.
https://osbuild.org
Apache License 2.0
108 stars 50 forks source link

No vcs version info in bib container #511

Closed mvo5 closed 2 months ago

mvo5 commented 2 months ago

While looking at https://github.com/osbuild/bootc-image-builder/pull/489#issuecomment-2197787396 I noticed we are not embedding the git revision of bib in our container. It seems like nice feature so I looked into enabling it. My approach so far:

diff --git a/Containerfile b/Containerfile
index 68a8297..9d3da64 100644
--- a/Containerfile
+++ b/Containerfile
@@ -6,7 +6,9 @@ RUN go env -w GOPROXY=$GOPROXY
 RUN cd /build/bib && go mod download
 COPY build.sh /build
 COPY bib /build/bib
+COPY .git /build
 WORKDIR /build
+RUN git rev-parse --short HEAD
 RUN ./build.sh

 FROM registry.fedoraproject.org/fedora:40

seems to be not working even though during the build git rev-parse will print the right output. When running

$ ./build.sh
$ strings bin/bootc-image-builder | grep vcs.revision
build   vcs.revision=8ecb710ba86cc655919dc619980bfd042d29fb63
build   vcs.revision=8ecb710ba86cc655919dc619980bfd042d29fb63

However doing the same inside the Containerfile does not yield the same result, it will just not contain a vcs.revision in buildinfo for unknown reasons.

diff --git a/build.sh b/build.sh
index 1c19119..29d2250 100755
--- a/build.sh
+++ b/build.sh
@@ -8,7 +8,9 @@ CONTAINERS_STORAGE_THIN_TAGS="containers_image_openpgp exclude_graphdriver_btrfs

 cd bib
 set -x
-go build -tags "${CONTAINERS_STORAGE_THIN_TAGS}" -o ../bin/bootc-image-builder ./cmd/bootc-image-builder
+go build -buildvcs=true -tags "${CONTAINERS_STORAGE_THIN_TAGS}" -o ../bin/bootc-image-builder ./cmd/bootc-image-builder
+git rev-parse --short HEAD
+strings ../bin/bootc-image-builder |grep vcs

 # expand the list as we support more architectures
 for arch in amd64 arm64; do

I'm parking this issue for now but I'm a bit puzzled why this is not working.

mvo5 commented 2 months ago

Found the issue, incorrect use of the COPY in the Containerfile - silly me!