Skip to content

Commit

Permalink
Fix OS PRETTY_NAME on tagged releases
Browse files Browse the repository at this point in the history
These were always showing up as dev due to the build arg not being set by the drone step.

Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Jan 5, 2024
1 parent b297996 commit eae221f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -496,7 +502,6 @@ steps:
- DOCKER_USERNAME
- DOCKER_PASSWORD
- DRONE_TAG

trigger:
instance:
- drone-publish.k3s.io
Expand Down
9 changes: 6 additions & 3 deletions package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/package-image
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit eae221f

Please sign in to comment.