Cleanup main makefile and remove the need of sed (#4995)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-01-31 22:56:55 -03:00 committed by GitHub
parent 3f94729c52
commit ee5595f5be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 40 deletions

View file

@ -42,7 +42,7 @@ endif
# Allow limiting the scope of the e2e tests. By default run everything # Allow limiting the scope of the e2e tests. By default run everything
FOCUS ?= .* FOCUS ?= .*
# number of parallel test # number of parallel test
E2E_NODES ?= 10 E2E_NODES ?= 12
# slow test only if takes > 50s # slow test only if takes > 50s
SLOW_E2E_THRESHOLD ?= 50 SLOW_E2E_THRESHOLD ?= 50
# run e2e test suite with tests that check for memory leaks? (default is false) # run e2e test suite with tests that check for memory leaks? (default is false)
@ -53,28 +53,18 @@ GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD)
PKG = k8s.io/ingress-nginx PKG = k8s.io/ingress-nginx
ALL_ARCH = amd64 arm arm64
BUSTED_ARGS =-v --pattern=_test BUSTED_ARGS =-v --pattern=_test
ARCH ?= $(shell go env GOARCH) ARCH ?= $(shell go env GOARCH)
BASEIMAGE_TAG = 26f574dc279aa853736d7f7249965e90e47171d6
REGISTRY ?= quay.io/kubernetes-ingress-controller REGISTRY ?= quay.io/kubernetes-ingress-controller
MULTI_ARCH_IMAGE = $(REGISTRY)/nginx-ingress-controller-${ARCH}
GOHOSTOS ?= $(shell go env GOHOSTOS) BASE_IMAGE ?= quay.io/kubernetes-ingress-controller/nginx
GOARCH = ${ARCH} BASE_TAG ?= 26f574dc279aa853736d7f7249965e90e47171d6
GOOS = linux
GOARCH=$(ARCH)
GOBUILD_FLAGS := -v GOBUILD_FLAGS := -v
# fix sed for osx
SED_I ?= sed -i
ifeq ($(GOHOSTOS),darwin)
SED_I=sed -i ''
endif
# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules # use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules
GO111MODULE=off GO111MODULE=off
@ -94,12 +84,6 @@ sub-container-%:
sub-push-%: ## Publish image for a particular arch. sub-push-%: ## Publish image for a particular arch.
$(MAKE) ARCH=$* push $(MAKE) ARCH=$* push
.PHONY: all-container
all-container: $(addprefix sub-container-,$(ALL_ARCH)) ## Build image for amd64, arm and arm64.
.PHONY: all-push
all-push: $(addprefix sub-push-,$(ALL_ARCH)) ## Publish images for amd64, arm and arm64.
.PHONY: container .PHONY: container
container: clean-container .container-$(ARCH) ## Build image for a particular arch. container: clean-container .container-$(ARCH) ## Build image for a particular arch.
@ -111,11 +95,7 @@ container: clean-container .container-$(ARCH) ## Build image for a particular ar
cp bin/$(ARCH)/dbg $(TEMP_DIR)/rootfs/dbg cp bin/$(ARCH)/dbg $(TEMP_DIR)/rootfs/dbg
cp bin/$(ARCH)/wait-shutdown $(TEMP_DIR)/rootfs/wait-shutdown cp bin/$(ARCH)/wait-shutdown $(TEMP_DIR)/rootfs/wait-shutdown
# Set default base image dynamically for each arch cp -RP rootfs/* $(TEMP_DIR)/rootfs
cp -RP ./* $(TEMP_DIR)
$(SED_I) "s|BASEIMAGE|quay.io/kubernetes-ingress-controller/nginx-$(ARCH):$(BASEIMAGE_TAG)|g" $(DOCKERFILE)
$(SED_I) "s|VERSION|$(TAG)|g" $(DOCKERFILE)
echo "Building docker image ($(ARCH))..." echo "Building docker image ($(ARCH))..."
# buildx assumes images are multi-arch # buildx assumes images are multi-arch
@ -125,12 +105,14 @@ container: clean-container .container-$(ARCH) ## Build image for a particular ar
--no-cache \ --no-cache \
--progress plain \ --progress plain \
--platform linux/$(ARCH) \ --platform linux/$(ARCH) \
-t $(MULTI_ARCH_IMAGE):$(TAG) $(TEMP_DIR)/rootfs --build-arg BASE_IMAGE="$(BASE_IMAGE)-$(ARCH):$(BASE_TAG)" \
--build-arg VERSION="$(TAG)" \
-t $(REGISTRY)/nginx-ingress-controller-${ARCH}:$(TAG) $(TEMP_DIR)/rootfs
.PHONY: clean-container .PHONY: clean-container
clean-container: ## Removes local image clean-container: ## Removes local image
echo "removing old image $(MULTI_ARCH_IMAGE):$(TAG)" echo "removing old image $(BASE_IMAGE)-$(ARCH):$(TAG)"
@docker rmi -f $(MULTI_ARCH_IMAGE):$(TAG) || true @docker rmi -f $(BASE_IMAGE)-$(ARCH):$(TAG) || true
.PHONY: push .PHONY: push
push: .push-$(ARCH) ## Publish image for a particular arch. push: .push-$(ARCH) ## Publish image for a particular arch.
@ -138,7 +120,7 @@ push: .push-$(ARCH) ## Publish image for a particular arch.
# internal task # internal task
.PHONY: .push-$(ARCH) .PHONY: .push-$(ARCH)
.push-$(ARCH): .push-$(ARCH):
docker push $(MULTI_ARCH_IMAGE):$(TAG) docker push $(BASE_IMAGE)-$(ARCH):$(TAG)
.PHONY: build .PHONY: build
build: check-go-version ## Build ingress controller, debug tool and pre-stop hook. build: check-go-version ## Build ingress controller, debug tool and pre-stop hook.
@ -235,10 +217,6 @@ cover: check-go-version ## Run go coverage unit tests.
vet: vet:
@go vet $(shell go list ${PKG}/internal/... | grep -v vendor) @go vet $(shell go list ${PKG}/internal/... | grep -v vendor)
.PHONY: release
release: all-container all-push ## Build and publish images of the ingress controller.
echo "done"
.PHONY: check_dead_links .PHONY: check_dead_links
check_dead_links: ## Check if the documentation contains dead links. check_dead_links: ## Check if the documentation contains dead links.
@docker run -t \ @docker run -t \

View file

@ -44,6 +44,7 @@ if [ "$missing" = true ]; then
fi fi
export CGO_ENABLED=0 export CGO_ENABLED=0
export GOARCH=${ARCH}
go build \ go build \
"${GOBUILD_FLAGS}" \ "${GOBUILD_FLAGS}" \

View file

@ -12,14 +12,17 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
FROM --platform=$BUILDPLATFORM BASEIMAGE ARG BASE_IMAGE
ARG VERSION
LABEL org.opencontainers.image.title='NGINX Ingress Controller for Kubernetes' FROM --platform=$BUILDPLATFORM ${BASE_IMAGE}
LABEL org.opencontainers.image.documentation='https://kubernetes.github.io/ingress-nginx/'
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.source="https://github.com/kubernetes/ingress-nginx"
LABEL org.opencontainers.image.vendor='The Kubernetes Authors' LABEL org.opencontainers.image.vendor="The Kubernetes Authors"
LABEL org.opencontainers.image.licenses='Apache-2.0' LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.version='VERSION' LABEL org.opencontainers.image.version="${VERSION}"
WORKDIR /etc/nginx WORKDIR /etc/nginx