Skip to content

Commit

Permalink
Add new Dockerfile label org.opencontainers.image.revision
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Aug 20, 2020
1 parent d34f021 commit 43ca5f5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ E2E_NODES ?= 8
E2E_CHECK_LEAKS ?=

REPO_INFO ?= $(shell git config --get remote.origin.url)
GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD)
COMMIT_SHA ?= git-$(shell git rev-parse --short HEAD)

PKG = k8s.io/ingress-nginx

Expand All @@ -65,6 +65,7 @@ image: clean-image ## Build image for a particular arch.
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \
--build-arg TARGETARCH="$(ARCH)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
-t $(REGISTRY)/controller:$(TAG) rootfs

.PHONY: clean-image
Expand All @@ -77,7 +78,7 @@ build: ## Build ingress controller, debug tool and pre-stop hook.
@build/run-in-docker.sh \
PKG=$(PKG) \
ARCH=$(ARCH) \
GIT_COMMIT=$(GIT_COMMIT) \
COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
Expand All @@ -88,7 +89,7 @@ build-plugin: ## Build ingress-nginx krew plugin.
@build/run-in-docker.sh \
PKG=$(PKG) \
ARCH=$(ARCH) \
GIT_COMMIT=$(GIT_COMMIT) \
COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
Expand All @@ -108,7 +109,7 @@ test: ## Run go unit tests.
@build/run-in-docker.sh \
PKG=$(PKG) \
ARCH=$(ARCH) \
GIT_COMMIT=$(GIT_COMMIT) \
COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
Expand Down Expand Up @@ -213,4 +214,5 @@ release: ensure-buildx clean
--platform $(subst $(SPACE),$(COMMA),$(PLATFORMS)) \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
-t $(REGISTRY)/controller:$(TAG) rootfs
4 changes: 2 additions & 2 deletions build/build-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare -a mandatory
mandatory=(
PKG
ARCH
GIT_COMMIT
COMMIT_SHA
REPO_INFO
TAG
)
Expand Down Expand Up @@ -56,7 +56,7 @@ function build_for_arch(){
"${GOBUILD_FLAGS}" \
-ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \
-o "${release}/kubectl-ingress_nginx${extension}" "${PKG}/cmd/plugin"

Expand Down
8 changes: 4 additions & 4 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare -a mandatory
mandatory=(
PKG
ARCH
GIT_COMMIT
COMMIT_SHA
REPO_INFO
TAG
)
Expand All @@ -49,20 +49,20 @@ export GOARCH=${ARCH}
go build \
-ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \
-o "rootfs/bin/${ARCH}/nginx-ingress-controller" "${PKG}/cmd/nginx"

go build \
-ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \
-o "rootfs/bin/${ARCH}/dbg" "${PKG}/cmd/dbg"

go build \
-ldflags "-s -w \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${GIT_COMMIT} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \
-o "rootfs/bin/${ARCH}/wait-shutdown" "${PKG}/cmd/waitshutdown"
1 change: 0 additions & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ steps:
entrypoint: bash
env:
- DOCKER_CLI_EXPERIMENTAL=enabled
- GIT_COMMIT=$_GIT_TAG
- REGISTRY=gcr.io/k8s-staging-ingress-nginx
- REPO_INFO=https://github.com/kubernetes/ingress-nginx
- HOME=/root
Expand Down
2 changes: 2 additions & 0 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ FROM ${BASE_IMAGE}

ARG TARGETARCH
ARG VERSION
ARG COMMIT_SHA

LABEL org.opencontainers.image.title="NGINX Ingress Controller for Kubernetes"
LABEL org.opencontainers.image.documentation="https://kubernetes.github.io/ingress-nginx/"
LABEL org.opencontainers.image.source="https://github.com/kubernetes/ingress-nginx"
LABEL org.opencontainers.image.vendor="The Kubernetes Authors"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="${COMMIT_SHA}"

WORKDIR /etc/nginx

Expand Down

0 comments on commit 43ca5f5

Please sign in to comment.