-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (78 loc) · 2.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
SHELL := /bin/bash
GO := go
NAME := cmg
OS := $(shell uname)
MAIN_GO := main.go
ROOT_PACKAGE := $(GIT_PROVIDER)/$(ORG)/$(NAME)
GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
PACKAGE_DIRS := $(shell $(GO) list ./... | grep -v /vendor/)
PKGS := $(shell go list ./... | grep -v /vendor | grep -v generated)
PKGS := $(subst :,_,$(PKGS))
BUILDFLAGS := ''
CGO_ENABLED = 0
VENDOR_DIR=vendor
LOCAL_VERSION = $(shell git describe --tags --always)
PACKAGE_VERSION ?= "0.3.0-$(LOCAL_VERSION)"
all: build
check: fmt build test
build:
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
test:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(PACKAGE_DIRS) -test.v -coverprofile cp.out
coverage:
gopherbadger-md="README.md"
full: $(PKGS)
install:
GOBIN=${GOPATH}/bin $(GO) install -ldflags $(BUILDFLAGS) $(MAIN_GO)
fmt:
@gofmt -s -w -l **/*.go
clean:
rm -rf build release
linux:
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO)
multiarch:
CGO_ENABLED=0 go build -o bin/$(NAME) $(MAIN_GO)
.PHONY: release clean
FGT := $(GOPATH)/bin/fgt
$(FGT):
go get github.com/GeertJohan/fgt
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
go get github.com/golang/lint/golint
$(PKGS): $(GOLINT) $(FGT)
@echo "LINTING"
@$(FGT) $(GOLINT) $(GOPATH)/src/$@/*.go
@echo "VETTING"
@go vet -v $@
@echo "TESTING"
@go test -v $@
.PHONY: lint
lint: vendor | $(PKGS) $(GOLINT) # ❷
@cd $(BASE) && ret=0 && for pkg in $(PKGS); do \
test -z "$$($(GOLINT) $$pkg | tee /dev/stderr)" || ret=1 ; \
done ; exit $$ret
watch:
reflex -r "\.go$" -R "vendor.*" make skaffold-run
skaffold-run: build
skaffold run -p dev
dbuild: fmt
DOCKER_BUILDKIT=1 docker build --tag caladreas/cmg:latest .
dclean:
docker rm cmg
drun:
docker run --name cmg -p 8080:8080 caladreas/cmg:latest serve
dpush: dbuild
docker push caladreas/cmg:latest
gbuild: fmt
gcloud builds submit --tag gcr.io/$(PROJECT_ID)/cmg
gpush: dbuild
docker tag caladreas/cmg:latest gcr.io/$(PROJECT_ID)/cmg:latest
docker push gcr.io/$(PROJECT_ID)/cmg:latest
gdeploy: gpush
gcloud run deploy cmg --image=gcr.io/$(PROJECT_ID)/cmg:latest --memory=128Mi --max-instances=2 --timeout=30 --project=$(PROJECT_ID) --platform managed --allow-unauthenticated --region=europe-west4
dxbuild:
docker buildx build . --platform linux/arm64,linux/amd64 --tag caladreas/cmg:0.29.1-c
# dxpush:
# docker buildx build . --platform linux/arm64,linux/amd64 --tag caladreas/cmg:0.3.1 --push
dxpush:
docker buildx build . --platform linux/arm64,linux/amd64 --tag ghcr.io/joostvdg/cmg:${PACKAGE_VERSION} --push