This repository was archived by the owner on May 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (65 loc) · 2.15 KB
/
Makefile
File metadata and controls
81 lines (65 loc) · 2.15 KB
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
.EXPORT_ALL_VARIABLES:
BIN_DIR := ./bin
OUT_DIR := ./output
$(shell mkdir -p $(BIN_DIR) $(OUT_DIR))
IMAGE_REGISTRY=cloudnativeid
IMAGE_NAME=$(IMAGE_REGISTRY)/community-system
IMAGE_TAG=$(shell git rev-parse --short HEAD)
CURRENT_DIR=$(shell pwd)
VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse --short HEAD)
GIT_TREE_STATE=$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
STATIC_BUILD?=true
override LDFLAGS += \
-X ${PACKAGE}.version=${VERSION} \
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
-X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}
ifeq (${STATIC_BUILD}, true)
override LDFLAGS += -extldflags "-static"
endif
ifneq (${GIT_TAG},)
IMAGE_TAG=${GIT_TAG}
IMAGE_TRACK=stable
LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
else
IMAGE_TAG?=$(GIT_COMMIT)
IMAGE_TRACK=latest
endif
.PHONY: swagger.update
swagger.update:
swagger generate server -f swagger.yaml -A community-system --default-scheme http --target=gen --exclude-main
.PHONY: test
test:
go get golang.org/x/tools/cmd/cover
go test -coverprofile=./output/coverage.out -race ./...
go tool cover -html=./output/coverage.out -o ./output/coverage.html
.PHONY: lint
lint:
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.41.1
golangci-lint run --verbose
.PHONY: dev.environment.up
dev.environment.up:
docker-compose up -d
.PHONY: dev.environment.down
dev.environment.down:
docker-compose down
.PHONY: dev.run
dev.run:
go run cmd/community-system-server/main.go --scheme http --port=8080 --host=0.0.0.0
.PHONY: build.binaries
build.binaries:
CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags '${LDFLAGS}' -o ${BIN_DIR}/community-system ./cmd/community-system-server/main.go
.PHONY: image.build
image.build:
echo "building container image"
DOCKER_BUILDKIT=1 docker build \
-t $(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg BUILDKIT_INLINE_CACHE=1 .
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest
.PHONY: image.release
image.release:
echo "pushing container image"
docker push $(IMAGE_NAME):latest
docker push $(IMAGE_NAME):$(IMAGE_TAG)