forked from kubernetes-sigs/kind
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.common.in
54 lines (47 loc) · 1.85 KB
/
Makefile.common.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# shared makefile for all images
# get image name from directory we're building
IMAGE_NAME?=$(notdir $(CURDIR))
# docker image registry, default to upstream
REGISTRY?=gcr.io/k8s-staging-kind
# for appending build-meta like "_containerd-v1.7.1"
TAG_SUFFIX?=
# tag based on date-sha
TAG?=$(shell echo "$$(date +v%Y%m%d)-$$(git describe --always --dirty)")
# the full image tag
IMAGE?=$(REGISTRY)/$(IMAGE_NAME):$(TAG)$(TAG_SUFFIX)
# Go version to use, respected by images that build go binaries
GO_VERSION=$(shell cat $(CURDIR)/../../.go-version | head -n1)
# build with buildx
PLATFORMS?=linux/amd64,linux/arm64
OUTPUT?=
PROGRESS=auto
EXTRA_BUILD_OPT?=
build: ensure-buildx
docker buildx build $(if $(PLATFORMS),--platform=$(PLATFORMS),) $(OUTPUT) --progress=$(PROGRESS) -t ${IMAGE} --pull --build-arg GO_VERSION=$(GO_VERSION) $(EXTRA_BUILD_OPT) .
# push the cross built image
push: OUTPUT=--push
push: build
# quick can be used to do a build that will be imported into the local docker
# for sanity checking before doing a cross build push
# cross builds cannot be imported locally at the moment
# https://github.com/docker/buildx/issues/59
quick: PLATFORMS=
quick: OUTPUT=--load
quick: build
# enable buildx
ensure-buildx:
./../../hack/build/init-buildx.sh
.PHONY: push build quick ensure-buildx