From 6f62b808d73ae856c5f49fe7c8b1d8b8c0e5c689 Mon Sep 17 00:00:00 2001 From: surtur Date: Wed, 20 Oct 2021 00:18:19 +0200 Subject: [PATCH] fix(kaniko): supply build args {in ci,locally} since the switch to kaniko as a container image builder, proper BUILD_DATE and VCS_REF values previously filled in by a build hook were left empty. that changes now. --- .drone.yml | 6 ++++++ Makefile | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index ec5b1f9..14d37af 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,6 +29,9 @@ steps: settings: dockerfile: Dockerfile context: . + args: + - BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + - VCS_REF=${DRONE_COMMIT_SHA:0:7} when: ref: - "refs/heads/feature-**" @@ -43,6 +46,9 @@ steps: settings: dockerfile: Dockerfile context: . + args: + - BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + - VCS_REF=${DRONE_COMMIT_SHA:0:7} tags: - latest - linux-amd64 diff --git a/Makefile b/Makefile index 269f469..7200839 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,9 @@ dargskaniko = run --rm -it -w=$(kanikowdir) -v $$PWD:$(kanikowdir) kanikoexecutorimg = gcr.io/kaniko-project/executor@sha256:6ecc43ae139ad8cfa11604b592aaedddcabff8cef469eda303f1fb5afe5e3034 kanikowdir = /src kanikocontext = . -kanikoargs = -f=$(dfile) -c=$(kanikocontext) --use-new-run --snapshotMode=redo --no-push +kanikoargs = -f=$(dfile) -c=$(kanikocontext) --use-new-run --snapshotMode=redo --build-arg BUILD_DATE=$(build_date) --build-arg VCS_REF=$(vcs_ref) --no-push +vcs_ref = $$(git rev-parse --short HEAD) +build_date= $$(date -u +"%Y-%m-%dT%H:%M:%SZ") hadolintimg = hadolint/hadolint:v2.7.0-alpine hadolintargs = run --rm -i -v $$PWD/.hadolint.yaml:/root/.config/hadolint.yaml