forked from caoyingjunz/csi-driver-localstorage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (44 loc) · 1.01 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
TARGET_DIR ?= ./dist
GOPROXY ?= https://goproxy.cn,direct
ARCH ?= amd64
OS ?= linux
apps ?= $(shell ls cmd)
BUILDX ?= false
PLATFORM ?= linux/amd64,linux/arm64
ORG ?= jacky06
TAG ?= v0.0.1
WHAT ?= all # selected all apps
ifneq ($(filter $(WHAT),$(apps)),)
apps := $(WHAT)
endif
.PHONY: build client-gen vendor image
build:
@$(foreach app, $(apps), CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) GOPROXY=$(GOPROXY) go build -o $(TARGET_DIR)/$(ARCH)/ ./cmd/$(app);)
client-gen: vendor
./hack/update-codegen.sh
vendor:
go mod vendor
image:
ifeq ($(BUILDX), false)
@$(foreach app, $(apps), \
docker build \
--build-arg GOPROXY=$(GOPROXY) \
--build-arg APP=$(app) \
--force-rm \
--no-cache \
-t $(ORG)/$(app):$(TAG) \
.;)
else
@$(foreach app, $(apps), \
docker buildx build \
--build-arg GOPROXY=$(GOPROXY) \
--build-arg APP=$(app) \
--force-rm \
--no-cache \
--platform $(PLATFORM) \
--push \
-t $(ORG)/$(app):$(TAG) \
.;)
endif
push:
@$(foreach app, $(apps), docker push $(ORG)/$(app):$(TAG);)