-
Notifications
You must be signed in to change notification settings - Fork 180
/
Makefile
47 lines (38 loc) · 1.38 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
.DEFAULT_GOAL := help
# plugin params
SHELL = /bin/bash
APP = veinmind-minio
CMD = cmd/cli.go
ARG = ""
# build params
IMAGE_TAG = latest
CI_GOOS = linux
CI_GOARCH=$(shell uname -m)
##@ Init
.PHONY: deps
deps: ## Install Dependencies.
ifeq ($(strip $(GITHUB_ACTIONS)),)
go env -w GOPROXY=https://goproxy.cn,direct
endif
go mod tidy
##@ Build
.PHONY: build
build: deps ## Build Apps.
go build -ldflags '-s -w' -v -trimpath -a -o ${APP} ${CMD}
.PHONY: build.platform
build.platform: deps ## Build Apps With Platform.
export CGO_ENABLED=1 GOOS="${CI_GOOS}" GOARCH="${CI_GOARCH}"; \
go build -ldflags '-s -w' -v -trimpath -a -o ${APP}_${CI_GOOS}_${CI_GOARCH} ${CMD}
.PHONY: build.docker
build.docker: ## Build Apps Docker Images.
docker build -t ${APP}:${IMAGE_TAG} .
##@ Run
.PHONY: run
run: deps ## Run Apps. e.g. : `make run ARG="scan iac xxxx"` .
go run ${CMD} ${ARG}
.PHONY: run.docker
run.docker: ## Run With Parallel Container Mode. e.g. : `make run.docker ARG="scan iac xxxx"` .
docker run --rm -it --mount 'type=bind,source=/,target=/host,readonly,bind-propagation=rslave' -v `pwd`:/tool/data registry.veinmind.tech/veinmind/${APP} ${ARG}
.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-\\.]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)