2020-05-17 19:14:14 +02:00
|
|
|
PACKAGE_NAME=./bin/hugo-mx-gateway
|
2020-05-17 19:59:22 +02:00
|
|
|
DOCKER_IMAGE_REPO=rchakode/hugo-mx-gateway
|
2020-05-10 00:02:18 +02:00
|
|
|
ARCH=$$(uname -m)
|
2020-05-17 19:14:14 +02:00
|
|
|
GOCMD=GO111MODULE=on go
|
2020-05-10 00:02:18 +02:00
|
|
|
GOBUILD=$(GOCMD) build
|
2020-05-23 23:25:12 +02:00
|
|
|
GOBUILD_FLAGS=-a -tags netgo -ldflags '-w -extldflags "-static"'
|
2020-05-10 00:02:18 +02:00
|
|
|
GOCLEAN=$(GOCMD) clean
|
|
|
|
GOTEST=$(GOCMD) test
|
2020-05-17 19:14:14 +02:00
|
|
|
GOVENDOR=$(GOCMD) mod vendor
|
|
|
|
GOIMAGE=golang:1.13.10
|
2020-05-10 00:02:18 +02:00
|
|
|
UPX=upx
|
|
|
|
|
2020-05-17 21:53:35 +02:00
|
|
|
all: deps test build
|
2020-05-10 00:02:18 +02:00
|
|
|
|
2020-05-17 21:53:35 +02:00
|
|
|
deps: vendor
|
|
|
|
vendor:
|
|
|
|
$(GOVENDOR)
|
|
|
|
|
2020-05-10 00:02:18 +02:00
|
|
|
build:
|
2020-05-23 23:25:12 +02:00
|
|
|
$(GOBUILD) $(GOBUILD_FLAGS) -o $(PACKAGE_NAME) -v
|
2020-05-10 00:02:18 +02:00
|
|
|
|
2020-05-17 19:59:22 +02:00
|
|
|
build-ci:
|
2020-05-31 16:07:00 +02:00
|
|
|
docker run --rm \
|
2020-05-17 19:14:14 +02:00
|
|
|
-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
|
2020-05-17 19:59:22 +02:00
|
|
|
|
|
|
|
container: build-ci
|
|
|
|
docker build -t $(DOCKER_IMAGE_REPO):$$(date +%s) .
|
2020-05-17 19:14:14 +02:00
|
|
|
|
2020-05-10 00:02:18 +02:00
|
|
|
build-compress: build
|
|
|
|
$(UPX) $(PACKAGE_NAME)
|
|
|
|
|
|
|
|
test:
|
|
|
|
$(GOCMD) clean -testcache
|
|
|
|
$(GOTEST) -v ./...
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(GOCLEAN)
|
|
|
|
rm -f $(PACKAGE_NAME)
|
|
|
|
|
|
|
|
run:
|
|
|
|
$(GOBUILD) -o $(PACKAGE_NAME) -v ./...
|
2020-05-17 19:14:14 +02:00
|
|
|
$(PACKAGE_NAME)
|
2020-05-10 00:02:18 +02:00
|
|
|
|
2020-05-17 21:53:35 +02:00
|
|
|
deploy-gcp:
|
|
|
|
which gcloud
|
|
|
|
gcloud components install app-engine-go
|
|
|
|
gcloud app deploy --quiet
|