-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
54 lines (44 loc) · 1.05 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
PACKAGE_NAME=./bin/hugo-mx-gateway
DOCKER_IMAGE_REPO=rchakode/hugo-mx-gateway
ARCH=$$(uname -m)
GOCMD=GO111MODULE=on go
GOBUILD=$(GOCMD) build
GOBUILD_FLAGS=-a -tags netgo -ldflags '-w -extldflags "-static"'
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOVENDOR=$(GOCMD) mod vendor
GOIMAGE=golang:1.13.10
UPX=upx
all: deps test build
deps: vendor
vendor:
$(GOVENDOR)
build:
env GOOS=linux GOARCH=amd64 $(GOBUILD) $(GOBUILD_FLAGS) -o $(PACKAGE_NAME) -v
build-ci:
docker run --rm \
-e GO111MODULE=on \
-e CGO_ENABLED=0 \
-e GOOS=linux \
-e GOARCH=amd64 \
-v "$(PWD)":/app \
-w /app \
$(GOIMAGE) \
go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o "$(PACKAGE_NAME)" -v
container: build-ci
docker build -t $(DOCKER_IMAGE_REPO):$$(date +%s) .
build-compress: build
$(UPX) $(PACKAGE_NAME)
test:
$(GOCMD) clean -testcache
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
rm -f $(PACKAGE_NAME)
run:
$(GOBUILD) -o $(PACKAGE_NAME) -v ./...
$(PACKAGE_NAME)
deploy-gcp:
which gcloud
gcloud components install app-engine-go
gcloud app deploy --quiet