forked from fydrah/loginapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (49 loc) · 1.49 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
# Dirs
BUILDDIR := build
CMDDIR := cmd
# Git
GIT_REPOSITORY := github.com/fydrah/loginapp
GIT_COMMIT_ID := $(shell git log -n 1 --pretty=format:%h)
GIT_TAG := $(shell git describe --tags)
# Go
GOFLAGS :=
LDFLAGS = -w -s -X "$(GIT_REPOSITORY)/cmd.GitVersion=$(GIT_TAG)" -X "$(GIT_REPOSITORY)/cmd.GitHash=$(GIT_COMMIT_ID)"
# Docker
DOCKERFILE := Dockerfile
DOCKER_REPOSITORY := quay.io/fydrah/loginapp
DOCKER_BIN := $(shell which docker || which podman || echo "docker")
DOCKER_BUILD := $(DOCKER_BIN) build -f $(DOCKERFILE) .
.PHONY: all
all: build
.PHONY: packr2
packr2:
which packr2 || go get -u github.com/gobuffalo/packr/v2/packr2
# packr2 still requires GO111MODULE var
GO111MODULE=on packr2 clean
GO111MODULE=on packr2
.PHONY: vendor
vendor:
go mod vendor
.PHONY: build
build: clean vendor packr2
packr2 clean
go build -mod=vendor -o $(BUILDDIR)/loginapp $(GOFLAGS) -ldflags '$(LDFLAGS)' $(GIT_REPOSITORY)
.PHONY: build-static
build-static: LDFLAGS += -extldflags "-static"
build-static: vendor packr2
CGO_ENABLED=0 go build -mod=vendor -o $(BUILDDIR)/loginapp $(GOFLAGS) -ldflags '$(LDFLAGS)' $(GIT_REPOSITORY)
.PHONY: docker-tmp
docker-tmp:
$(DOCKER_BUILD) -t $(DOCKER_REPOSITORY):$(GIT_COMMIT_ID)
.PHONY: gofmt
gofmt:
go fmt ./...
.PHONY: helmdoc
helmdoc:
chart-doc-gen -d docs/chart.yaml -v=helm/loginapp/values.yaml > ./helm/loginapp/README.md
.PHONY: helmpackage
helmpackage: helmdoc
helm package helm/loginapp -d $(BUILDDIR)
.PHONY: clean
clean:
rm -f $(BUILDDIR)/loginapp