Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup main makefile and remove the need of sed #4995

Merged
merged 1 commit into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 12 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif
# Allow limiting the scope of the e2e tests. By default run everything
FOCUS ?= .*
# number of parallel test
E2E_NODES ?= 10
E2E_NODES ?= 12
# slow test only if takes > 50s
SLOW_E2E_THRESHOLD ?= 50
# run e2e test suite with tests that check for memory leaks? (default is false)
Expand All @@ -53,27 +53,17 @@ GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD)

PKG = k8s.io/ingress-nginx

ALL_ARCH = amd64 arm arm64

BUSTED_ARGS =-v --pattern=_test

ARCH ?= $(shell go env GOARCH)

BASEIMAGE_TAG = 26f574dc279aa853736d7f7249965e90e47171d6

REGISTRY ?= quay.io/kubernetes-ingress-controller
MULTI_ARCH_IMAGE = $(REGISTRY)/nginx-ingress-controller-${ARCH}

GOHOSTOS ?= $(shell go env GOHOSTOS)
GOARCH = ${ARCH}
GOOS = linux
GOBUILD_FLAGS := -v
BASE_IMAGE ?= quay.io/kubernetes-ingress-controller/nginx
BASE_TAG ?= 26f574dc279aa853736d7f7249965e90e47171d6

# fix sed for osx
SED_I ?= sed -i
ifeq ($(GOHOSTOS),darwin)
SED_I=sed -i ''
endif
GOARCH=$(ARCH)
GOBUILD_FLAGS := -v

# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules
GO111MODULE=off
Expand All @@ -94,12 +84,6 @@ sub-container-%:
sub-push-%: ## Publish image for a particular arch.
$(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
container: clean-container .container-$(ARCH) ## Build image for a particular arch.

Expand All @@ -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)/wait-shutdown $(TEMP_DIR)/rootfs/wait-shutdown

# Set default base image dynamically for each arch

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)
cp -RP rootfs/* $(TEMP_DIR)/rootfs

echo "Building docker image ($(ARCH))..."
# buildx assumes images are multi-arch
Expand All @@ -125,20 +105,22 @@ container: clean-container .container-$(ARCH) ## Build image for a particular ar
--no-cache \
--progress plain \
--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
clean-container: ## Removes local image
echo "removing old image $(MULTI_ARCH_IMAGE):$(TAG)"
@docker rmi -f $(MULTI_ARCH_IMAGE):$(TAG) || true
echo "removing old image $(BASE_IMAGE)-$(ARCH):$(TAG)"
@docker rmi -f $(BASE_IMAGE)-$(ARCH):$(TAG) || true

.PHONY: push
push: .push-$(ARCH) ## Publish image for a particular arch.

# internal task
.PHONY: .push-$(ARCH)
.push-$(ARCH):
docker push $(MULTI_ARCH_IMAGE):$(TAG)
docker push $(BASE_IMAGE)-$(ARCH):$(TAG)

.PHONY: build
build: check-go-version ## Build ingress controller, debug tool and pre-stop hook.
Expand Down Expand Up @@ -235,10 +217,6 @@ cover: check-go-version ## Run go coverage unit tests.
vet:
@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
check_dead_links: ## Check if the documentation contains dead links.
@docker run -t \
Expand Down
1 change: 1 addition & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ if [ "$missing" = true ]; then
fi

export CGO_ENABLED=0
export GOARCH=${ARCH}

go build \
"${GOBUILD_FLAGS}" \
Expand Down
15 changes: 9 additions & 6 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=$BUILDPLATFORM BASEIMAGE
ARG BASE_IMAGE
ARG VERSION

LABEL org.opencontainers.image.title='NGINX Ingress Controller for Kubernetes'
LABEL org.opencontainers.image.documentation='https://kubernetes.github.io/ingress-nginx/'
FROM --platform=$BUILDPLATFORM ${BASE_IMAGE}

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.vendor="The Kubernetes Authors"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.version="${VERSION}"

WORKDIR /etc/nginx

Expand Down