From eae221f9e5a51bae015331f1736b972a9a590a94 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 15 Dec 2023 01:42:05 +0000 Subject: [PATCH] Fix OS PRETTY_NAME on tagged releases These were always showing up as dev due to the build arg not being set by the drone step. Signed-off-by: Brad Davidson --- .drone.yml | 7 ++++++- package/Dockerfile | 9 ++++++--- scripts/package-image | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index a555007c91..c9b538dc90 100644 --- a/.drone.yml +++ b/.drone.yml @@ -102,6 +102,8 @@ steps: repo: "rancher/k3s" username: from_secret: docker_username + build_args_from_env: + - DRONE_TAG when: instance: - drone-publish.k3s.io @@ -270,6 +272,8 @@ steps: repo: "rancher/k3s" username: from_secret: docker_username + build_args_from_env: + - DRONE_TAG when: instance: - drone-publish.k3s.io @@ -379,6 +383,8 @@ steps: repo: "rancher/k3s" username: from_secret: docker_username + build_args_from_env: + - DRONE_TAG when: instance: - drone-publish.k3s.io @@ -496,7 +502,6 @@ steps: - DOCKER_USERNAME - DOCKER_PASSWORD - DRONE_TAG - trigger: instance: - drone-publish.k3s.io diff --git a/package/Dockerfile b/package/Dockerfile index cbecc7792a..d50c189cd1 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -5,14 +5,17 @@ RUN mkdir -p /image/etc/ssl/certs /image/run /image/var/run /image/tmp /image/li tar -xa -C /image -f /data.tar.zst && \ cp /etc/ssl/certs/ca-certificates.crt /image/etc/ssl/certs/ca-certificates.crt -FROM scratch -ARG VERSION="dev" +FROM scratch as collect +ARG DRONE_TAG="dev" COPY --from=base /image / COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo RUN mkdir -p /etc && \ echo 'hosts: files dns' > /etc/nsswitch.conf && \ - echo "PRETTY_NAME=\"K3s ${VERSION}\"" > /etc/os-release && \ + echo "PRETTY_NAME=\"K3s ${DRONE_TAG}\"" > /etc/os-release && \ chmod 1777 /tmp + +FROM scratch +COPY --from=collect / / VOLUME /var/lib/kubelet VOLUME /var/lib/rancher/k3s VOLUME /var/lib/cni diff --git a/scripts/package-image b/scripts/package-image index cbc1d34d2d..823511d4d4 100755 --- a/scripts/package-image +++ b/scripts/package-image @@ -14,6 +14,6 @@ PROXY_OPTS= [ -z "$http_proxy" ] || PROXY_OPTS="$PROXY_OPTS --build-arg http_proxy=$http_proxy" [ -z "$https_proxy" ] || PROXY_OPTS="$PROXY_OPTS --build-arg https_proxy=$https_proxy" [ -z "$no_proxy" ] || PROXY_OPTS="$PROXY_OPTS --build-arg no_proxy=$no_proxy" -docker build ${PROXY_OPTS} --build-arg VERSION=${VERSION} -t ${IMAGE} -f package/Dockerfile . +docker build ${PROXY_OPTS} --build-arg DRONE_TAG=${VERSION_TAG} -t ${IMAGE} -f package/Dockerfile . ./scripts/image_scan.sh ${IMAGE} ${ARCH} echo Built ${IMAGE}