diff --git a/Dockerfile b/Dockerfile index 7c55d73b4..6b072222c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,6 @@ ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.13 ARG RELEASE_IMAGE=scratch FROM ${GO_IMAGE} as builder -LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode' \ - org.opencontainers.image.url='https://airshipit.org' \ - org.opencontainers.image.documentation='https://docs.airshipit.org/airshipctl/' \ - org.opencontainers.image.source='https://opendev.org/airship/airshipctl' \ - org.opencontainers.image.vendor='The Airship Authors' \ - org.opencontainers.image.licenses='Apache-2.0' - ENV PATH "/usr/local/go/bin:$PATH" # Inject custom root certificate authorities if needed @@ -32,6 +25,14 @@ ARG MAKE_TARGET=build RUN for target in $MAKE_TARGET; do make $target; done FROM ${RELEASE_IMAGE} as release + +LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode' \ + org.opencontainers.image.url='https://airshipit.org' \ + org.opencontainers.image.documentation='https://docs.airshipit.org/airshipctl/' \ + org.opencontainers.image.source='https://opendev.org/airship/airshipctl' \ + org.opencontainers.image.vendor='The Airship Authors' \ + org.opencontainers.image.licenses='Apache-2.0' + ARG BINARY=airshipctl ENV BINARY=${BINARY} COPY --from=builder /usr/src/airshipctl/bin/${BINARY} /usr/local/bin/${BINARY} diff --git a/Makefile b/Makefile index 9ee8339fc..0fa66c96b 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,9 @@ DOCKER_IMAGE_TAG ?= latest DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) DOCKER_TARGET_STAGE ?= release PUBLISH ?= false +# use this variable for image labels added in internal build process +LABEL ?= org.airshipit.build=community +COMMIT ?= $(shell git rev-parse HEAD) # go options PKG ?= ./... @@ -141,6 +144,10 @@ images: $(PLUGINS_IMAGE_TGT) .PHONY: docker-image docker-image: @docker build . $(DOCKER_CMD_FLAGS) \ + --label $(LABEL) \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(DOCKER_IMAGE_NAME)" \ --target $(DOCKER_TARGET_STAGE) \ --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \ --tag $(DOCKER_IMAGE) @@ -152,6 +159,10 @@ endif $(PLUGINS_IMAGE_TGT): $(eval plugin_name=$(subst docker-image-,,$@)) @docker build . $(DOCKER_CMD_FLAGS) \ + --label $(LABEL) \ + --label "org.opencontainers.image.revision=$(COMMIT)" \ + --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \ + --label "org.opencontainers.image.title=$(DOCKER_IMAGE_NAME)" \ --target $(DOCKER_TARGET_STAGE) \ --build-arg MAKE_TARGET=$(plugin_name) \ --build-arg BINARY=$(plugin_name) \