feat(Makefile): make local builds behave like CI

RUNTIME_BASE and BUILDTIME_BASE are both consumed in the Dockerfile and
handle setting the base containers used for both building and running
kube-router. These are handled differently in CI using GitHub actions
than they are for local builds.

This updates the Makefile so that local builds behave the same way that
CI based builds in GitHub are when it comes to these bases.
This commit is contained in:
Aaron U'Ren 2022-10-19 16:38:02 -05:00 committed by Manuel Rüger
parent efd100154f
commit 0813b7652b

View File

@ -18,6 +18,10 @@ MAKEFILE_DIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
UPSTREAM_IMPORT_PATH=$(GOPATH)/src/github.com/cloudnativelabs/kube-router/
BUILD_IN_DOCKER?=true
DOCKER_BUILD_IMAGE?=golang:1.19.2-alpine3.16
## These variables are used by the Dockerfile as the bases for building and creating the runtime container
## During CI these come from .github/workflows/ci.yaml below we define for local builds as well
BUILDTIME_BASE?=$(DOCKER_BUILD_IMAGE)
RUNTIME_BASE?=alpine:3.16
DOCKER_LINT_IMAGE?=golangci/golangci-lint:v1.49.0
GOBGP_VERSION=v3.5.0
QEMU_IMAGE?=multiarch/qemu-user-static
@ -91,7 +95,8 @@ container: kube-router gobgp multiarch-binverify ## Builds a Docker container im
echo "Using qemu to build non-native container"; \
$(DOCKER) run --rm --privileged $(QEMU_IMAGE) --reset -p yes; \
fi
$(DOCKER) build -t "$(REGISTRY_DEV):$(subst /,,$(IMG_TAG))" -f Dockerfile --build-arg ARCH="$(DOCKER_ARCH)" .
$(DOCKER) build -t "$(REGISTRY_DEV):$(subst /,,$(IMG_TAG))" -f Dockerfile --build-arg ARCH="$(DOCKER_ARCH)" \
--build-arg BUILDTIME_BASE="$(BUILDTIME_BASE)" --build-arg RUNTIME_BASE="$(RUNTIME_BASE)" .
@if [ "$(GIT_BRANCH)" = "master" ]; then \
$(DOCKER) tag "$(REGISTRY_DEV):$(IMG_TAG)" "$(REGISTRY_DEV)"; \
fi