Skip to content

Commit 8fc92f8

Browse files
authored
fix: improve container image OCI metadata and versioning (#480)
Signed-off-by: Todd Ekenstam <[email protected]>
1 parent bd8fb2a commit 8fc92f8

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

.github/workflows/image-push.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ jobs:
4343
org.opencontainers.image.url=https://github.com/keikoproj/instance-manager/blob/master/README.md
4444
org.opencontainers.image.vendor=keikoproj
4545
org.opencontainers.image.authors=Keikoproj Contributors
46-
org.opencontainers.image.created={{date 'ISO8601'}}
47-
org.opencontainers.image.version={{version}}
48-
org.opencontainers.image.revision={{git.sha}}
46+
org.opencontainers.image.created=${{ github.event.repository.updated_at }}
47+
org.opencontainers.image.version=${{ github.ref_name }}
48+
org.opencontainers.image.revision=${{ github.sha }}
49+
org.opencontainers.image.title=Instance Manager
4950
5051
- name: Build for ${{ matrix.platform }}
5152
uses: docker/build-push-action@v6
@@ -107,9 +108,10 @@ jobs:
107108
org.opencontainers.image.url=https://github.com/keikoproj/instance-manager/blob/master/README.md
108109
org.opencontainers.image.vendor=keikoproj
109110
org.opencontainers.image.authors=Keikoproj Contributors
110-
org.opencontainers.image.created={{date 'ISO8601'}}
111-
org.opencontainers.image.version={{version}}
112-
org.opencontainers.image.revision={{git.sha}}
111+
org.opencontainers.image.created=${{ github.event.repository.updated_at }}
112+
org.opencontainers.image.version=${{ github.ref_name }}
113+
org.opencontainers.image.revision=${{ github.sha }}
114+
org.opencontainers.image.title=Instance Manager
113115
114116
- name: Create manifest list and push
115117
id: push
@@ -128,9 +130,10 @@ jobs:
128130
annotation-index.org.opencontainers.image.url=https://github.com/keikoproj/instance-manager/blob/master/README.md
129131
annotation-index.org.opencontainers.image.vendor=keikoproj
130132
annotation-index.org.opencontainers.image.authors=Keikoproj Contributors
131-
annotation-index.org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
133+
annotation-index.org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%S.%3NZ')
132134
annotation-index.org.opencontainers.image.version=${{ github.ref_name }}
133135
annotation-index.org.opencontainers.image.revision=${{ github.sha }}
136+
annotation-index.org.opencontainers.image.title=Instance Manager
134137
135138
- name: Generate artifact attestation (dockerhub)
136139
uses: actions/attest-build-provenance@v2

Makefile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ GO_LDFLAGS ?= -ldflags="-s -w"
2727

2828
# Image URL to use all building/pushing image targets
2929
IMG ?= instance-manager:latest
30-
INSTANCEMGR_TAG ?= latest
30+
GIT_COMMIT := $(shell git rev-parse HEAD)
31+
GIT_SHORT_SHA := $(shell git rev-parse --short HEAD)
32+
GIT_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
33+
GIT_DIRTY := $(shell test -n "`git status --porcelain`" && echo "-dirty" || echo "")
34+
INSTANCEMGR_TAG ?= $(GIT_TAG)-$(GIT_SHORT_SHA)$(GIT_DIRTY)
35+
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
3136

3237
.PHONY: all
3338
all: check-go lint test clean manager
@@ -99,7 +104,19 @@ generate: controller-gen
99104
# Build the docker image
100105
.PHONY: docker-build
101106
docker-build:
102-
docker build . -t ${IMG}
107+
docker build . -t ${IMG} \
108+
--build-arg CREATED=$(BUILD_DATE) \
109+
--build-arg VERSION=$(INSTANCEMGR_TAG) \
110+
--label "org.opencontainers.image.created=$(BUILD_DATE)" \
111+
--label "org.opencontainers.image.version=$(INSTANCEMGR_TAG)" \
112+
--label "org.opencontainers.image.revision=$(GIT_COMMIT)" \
113+
--label "org.opencontainers.image.title=Instance Manager" \
114+
--label "org.opencontainers.image.description=A Kubernetes controller for creating and managing worker node instance groups across multiple providers" \
115+
--label "org.opencontainers.image.licenses=Apache-2.0" \
116+
--label "org.opencontainers.image.source=https://github.com/keikoproj/instance-manager" \
117+
--label "org.opencontainers.image.url=https://github.com/keikoproj/instance-manager/blob/master/README.md" \
118+
--label "org.opencontainers.image.vendor=keikoproj" \
119+
--label "org.opencontainers.image.authors=Keikoproj Contributors"
103120

104121
# Push the docker image
105122
.PHONY: docker-push

0 commit comments

Comments
 (0)