2019-05-07 14:53:13 -07:00
|
|
|
# Copyright 2019 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.
|
|
|
|
|
|
|
|
|
|
# Simple makefile to build kind quickly and reproducibly in a container
|
|
|
|
|
# Only requires docker on the host
|
|
|
|
|
|
|
|
|
|
# settings
|
2019-05-07 17:41:33 -07:00
|
|
|
REPO_ROOT=$(PWD)
|
|
|
|
|
# autodetect host GOOS and GOARCH by default, even if go is not installed
|
2019-05-07 18:42:22 -07:00
|
|
|
GOOS=$(shell hack/util/goos.sh)
|
|
|
|
|
GOARCH=$(shell hack/util/goarch.sh)
|
2019-05-07 17:49:32 -07:00
|
|
|
# use the official module proxy by default
|
|
|
|
|
GOPROXY=https://proxy.golang.org
|
2019-05-07 17:41:33 -07:00
|
|
|
# default build image
|
2019-05-08 08:35:47 +08:00
|
|
|
GO_VERSION=1.12.5
|
2019-05-07 14:53:13 -07:00
|
|
|
GO_IMAGE=golang:$(GO_VERSION)
|
2019-05-07 17:41:33 -07:00
|
|
|
# docker volume name, used as a go module / build cache
|
2019-05-07 14:53:13 -07:00
|
|
|
CACHE_VOLUME=kind-build-cache
|
|
|
|
|
|
|
|
|
|
# variables for consistent logic, don't override these
|
|
|
|
|
CONTAINER_REPO_DIR=/src/kind
|
|
|
|
|
CONTAINER_OUT_DIR=$(CONTAINER_REPO_DIR)/_output/bin
|
|
|
|
|
|
|
|
|
|
# standard "make" target -> builds
|
|
|
|
|
all: build
|
|
|
|
|
|
|
|
|
|
# creates the cache volume
|
|
|
|
|
make-cache:
|
|
|
|
|
docker volume create $(CACHE_VOLUME)
|
|
|
|
|
|
|
|
|
|
# cleans the cache volume
|
|
|
|
|
clean-cache:
|
|
|
|
|
docker volume rm $(CACHE_VOLUME)
|
|
|
|
|
|
|
|
|
|
# builds kind in a container, outputs to $(REPO_ROOT)/_output/bin
|
|
|
|
|
kind: make-cache
|
|
|
|
|
docker run \
|
|
|
|
|
--rm \
|
|
|
|
|
-v $(CACHE_VOLUME):/go \
|
|
|
|
|
-e GOCACHE=/go/cache \
|
|
|
|
|
-v $(REPO_ROOT):$(CONTAINER_REPO_DIR) \
|
|
|
|
|
-w $(CONTAINER_REPO_DIR) \
|
2019-05-07 17:49:32 -07:00
|
|
|
-e GO111MODULE=on \
|
|
|
|
|
-e GOPROXY=$(GOPROXY) \
|
2019-05-07 17:41:33 -07:00
|
|
|
-e CGO_ENABLED=0 \
|
|
|
|
|
-e GOOS=$(GOOS) \
|
|
|
|
|
-e GOARCH=$(GOARCH) \
|
2019-05-07 14:53:13 -07:00
|
|
|
$(GO_IMAGE) \
|
|
|
|
|
go build -v -o $(CONTAINER_OUT_DIR)/kind .
|
|
|
|
|
|
|
|
|
|
# alias for building kind
|
|
|
|
|
build: kind
|
|
|
|
|
|
|
|
|
|
# standard cleanup target
|
|
|
|
|
clean: clean-cache
|
|
|
|
|
|
|
|
|
|
.PHONY: make-cache clean-cache kind build all clean
|