Add commit and other labels to the airshipctl container image

Relates-To: #399

Change-Id: I0e0be8fe6dd37b346637ae9847523e4cd3734081
This commit is contained in:
Roman Gorshunov 2020-11-10 16:56:28 +01:00
parent 42e7dea246
commit de72491f2c
2 changed files with 19 additions and 7 deletions

View File

@ -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}

View File

@ -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) \