forked from cert-manager/cert-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (140 loc) · 4.74 KB
/
Makefile
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Copyright 2020 The cert-manager 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.
# STANDARD OPTIONS
###############
# Set DOCKER_REGISTRY to customise the image docker repo, e.g. "quay.io/jetstack"
DOCKER_REGISTRY :=
# Set APP_VERSION to customize the image tag, eg "v0.0.5-dev"
APP_VERSION :=
# Set the target platform to build for. Defaults to linux/amd64
PLATFORM := @io_bazel_rules_go//go/toolchain:linux_amd64
# OPTIONS YOU PROBABLY DON'T NEED TO MODIFY UNLESS DOING SOMETHING VERY SPECIFIC.
###############
# Set an alternative base image https://github.com/jetstack/cert-manager/blob/master/build/BUILD.bazel#L42
BASE_IMAGE := static
BAZEL_IMAGES_FLAGS := --define image_type=$(BASE_IMAGE)
# Ensure non cgo by default
# https://github.com/bazelbuild/rules_go/blob/master/go/modes.rst#building-pure-go-binaries
CGO_ENABLED := 0
ifeq ($(CGO_ENABLED),0)
BAZEL_IMAGES_FLAGS += --@io_bazel_rules_go//go/config:pure
endif
# Where the hack scripts live
HACK_DIR ?= hack
# Get a list of all binaries to be built
CMDS := $(shell find ./cmd/ -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
.PHONY: help
help:
# This Makefile provides common wrappers around Bazel invocations.
#
### Verify targets
#
# verify - runs all test targets (bazel test //...)
# verify_deps - ensure go module files are up to date (hack/update-deps.sh)
# verify_chart - runs Helm chart linter
# verify_upgrade - verifies upgrade from latest published release to current master with both Helm charts and static manifests
#
### Generate targets
#
# generate - regenerate all generated files
#
### Build targets
#
# clean - removes the entire output base tree, stops the Bazel server and removes test artifacts
# build - build a binary of the cert-manager CLI and build docker images for all components
# controller - build a binary of the 'controller'
# cainjector - build a binary of the 'cainjector'
# webhook - build a binary of the 'webhook'
# acmesolver - build a binary of the 'acmesolver'
# ctl - build a binary of the cert-manager CLI
# images - builds docker images for all of the components, saving them in your Docker daemon
# images_push - pushes docker images to the target registry
# crds - runs the update-crds script to ensure that generated CRDs are up to date
# cluster - creates a Kubernetes cluster for testing in CI (KIND by default)
# release_tars - build the release tar files.
#
# All image targets can be run with optional args DOCKER_REGISTRY, APP_VERSION, PLATFORM:
#
# make images DOCKER_REGISTRY=quay.io/yourusername APP_VERSION=v0.11.0-dev.my-feature PLATFORM=@io_bazel_rules_go//go/toolchain:linux_arm64
#
# make images_push DOCKER_REGISTRY=quay.io/yourusername APP_VERSION=v0.11.0-dev.my-feature
# Alias targets
###############
.PHONY: clean
clean:
bazel clean --expunge
rm -rf \
$(CURDIR)/_artifacts
.PHONY: build
build: ctl images
.PHONY: verify
verify:
bazel test //...
# TODO: remove this rule in favour of calling hack/verify-deps directly
.PHONY: verify_deps
verify_deps:
$(HACK_DIR)/verify-deps.sh
# verify-deps-licenses.sh is implicitly checked by the verify-deps script
# requires docker
.PHONY: verify_chart
verify_chart:
$(HACK_DIR)/verify-chart-version.sh
.PHONY: verify_upgrade
verify_upgrade:
$(HACK_DIR)/verify-upgrade.sh
.PHONY: crds
crds:
bazel run //hack:update-crds
.PHONY: cluster
cluster:
./devel/ci-cluster.sh
# Go targets
############
.PHONY: $(CMDS)
$(CMDS):
bazel build //cmd/$@
# Generate targets
##################
.PHONY: generate
generate:
$(HACK_DIR)/update-all.sh
# Docker targets
################
.PHONY: images
images:
APP_VERSION=$(APP_VERSION) \
DOCKER_REGISTRY=$(DOCKER_REGISTRY) \
bazel run \
--stamp \
--platforms=$(PLATFORM) \
$(BAZEL_IMAGES_FLAGS) \
//build:server-images
.PHONY: images_push
images_push:
APP_VERSION=$(APP_VERSION) \
DOCKER_REGISTRY=$(DOCKER_REGISTRY) \
bazel run \
--stamp \
--platforms=$(PLATFORM) \
$(BAZEL_IMAGES_FLAGS) \
//:images.push
# Release targets
################
.PHONY: release_tars
release_tars:
DOCKER_REGISTRY=$(DOCKER_REGISTRY) \
bazel build \
--stamp \
--platforms=$(PLATFORM) \
//build/release-tars