From 3d3ddc4ea39d5bfcfc7dfa131c926d1e718a6043 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 16 Apr 2024 14:24:10 +0200 Subject: [PATCH 1/3] Add labels org.opencontainers.image.source and org.opencontainers.image.revision --- Earthfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Earthfile b/Earthfile index ca6b7a1e..19778a7f 100644 --- a/Earthfile +++ b/Earthfile @@ -207,23 +207,33 @@ set-version: RUN git describe --tags --always > VERSION SAVE ARTIFACT VERSION +set-revision: + FROM alpine/git + COPY .git .git + RUN git rev-parse HEAD > REVISION + SAVE ARTIFACT REVISION + ci: FROM busybox COPY +set-version/VERSION . - BUILD +docker --CONTROLLER=yawol-controller --DOCKER_TAG=$(cat VERSION) - BUILD +docker --CONTROLLER=yawol-cloud-controller --DOCKER_TAG=$(cat VERSION) + COPY +set-revision/REVISION . + BUILD +docker --CONTROLLER=yawol-controller --DOCKER_TAG=$(cat VERSION) --REVISION=$(cat REVISION) + BUILD +docker --CONTROLLER=yawol-cloud-controller --DOCKER_TAG=$(cat VERSION) --REVISION=$(cat REVISION) docker: ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ARG DOCKER_TAG + ARG REVISION ARG CONTROLLER FROM --platform=$TARGETPLATFORM \ gcr.io/distroless/static:nonroot COPY --platform=$USERPLATFORM \ (+build/controller --CONTROLLER=$CONTROLLER --GOOS=$TARGETOS --GOARCH=$TARGETARCH) /controller BUILD +set-version + LABEL org.opencontainers.image.source="https://github.com/stackitcloud/yawol" + LABEL org.opencontainers.image.revision=$REVISION USER 65532:65532 ENTRYPOINT ["/controller"] SAVE IMAGE --push $DOCKER_REPO$CONTROLLER:$DOCKER_TAG From 86b865d0731244c9a582e096334ce1d37bcc98fa Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 16 Apr 2024 14:32:57 +0200 Subject: [PATCH 2/3] Remove `BUILD +set-version` --- Earthfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Earthfile b/Earthfile index 19778a7f..f032ca9e 100644 --- a/Earthfile +++ b/Earthfile @@ -231,7 +231,6 @@ docker: gcr.io/distroless/static:nonroot COPY --platform=$USERPLATFORM \ (+build/controller --CONTROLLER=$CONTROLLER --GOOS=$TARGETOS --GOARCH=$TARGETARCH) /controller - BUILD +set-version LABEL org.opencontainers.image.source="https://github.com/stackitcloud/yawol" LABEL org.opencontainers.image.revision=$REVISION USER 65532:65532 From fe90cde6981666c109175811b01d48d0842b5cc0 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 16 Apr 2024 16:11:01 +0200 Subject: [PATCH 3/3] Add org.opencontainers.image.version --- Earthfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Earthfile b/Earthfile index f032ca9e..68434da6 100644 --- a/Earthfile +++ b/Earthfile @@ -233,6 +233,7 @@ docker: (+build/controller --CONTROLLER=$CONTROLLER --GOOS=$TARGETOS --GOARCH=$TARGETARCH) /controller LABEL org.opencontainers.image.source="https://github.com/stackitcloud/yawol" LABEL org.opencontainers.image.revision=$REVISION + LABEL org.opencontainers.image.version=$DOCKER_TAG USER 65532:65532 ENTRYPOINT ["/controller"] SAVE IMAGE --push $DOCKER_REPO$CONTROLLER:$DOCKER_TAG