-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
42 lines (31 loc) · 924 Bytes
/
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
PWD := ${CURDIR}
OS = $(shell uname)
ALL_SRC = $(shell find . -name "*.go" | grep -v -e "vendor")
PACKAGE_VERSION ?= latest
REGISTRY ?= quay.io/amitkumardas
IMG_NAME ?= cstorpoolauto
all: bins
bins: vendor $(IMG_NAME)
$(IMG_NAME): $(ALL_SRC)
@echo "+ Generating $(IMG_NAME) binary"
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on \
go build -o $@ ./cmd/main.go
$(ALL_SRC): ;
# go mod download modules to local cache
# make vendored copy of dependencies
# install other go binaries for code generation
.PHONY: vendor
vendor: go.mod go.sum
@GO111MODULE=on go mod download
@GO111MODULE=on go mod tidy
@GO111MODULE=on go mod vendor
.PHONY: test
test:
@go test -cover ./...
.PHONY: image
image:
docker build -t $(REGISTRY)/$(IMG_NAME):$(PACKAGE_VERSION) .
docker image prune -f --filter label=type=intermediate-container
.PHONY: push
push: image
docker push $(REGISTRY)/$(IMG_NAME):$(PACKAGE_VERSION)