-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
43 lines (32 loc) · 1.08 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
NAME=x-gateway
IMAGE_NAME=docker.pkg.github.com/micro-in-cn/$(NAME)
GIT_COMMIT=$(shell git rev-parse --short HEAD)
GIT_TAG=$(shell git describe --abbrev=0 --tags --always --match "v*")
GIT_IMPORT=github.com/micro-in-cn/x-gateway/cmd
CGO_ENABLED=0
BUILD_DATE=$(shell date +%s)
LDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT) -X $(GIT_IMPORT).GitTag=$(GIT_TAG) -X $(GIT_IMPORT).BuildDate=$(BUILD_DATE)
IMAGE_TAG=$(GIT_TAG)-$(GIT_COMMIT)
all: build
vendor:
go mod vendor
vet:
go vet ./...
test: vet
go test -v ./...
clean:
rm -rf ./x-gateway
build:
go build -a -installsuffix cgo -ldflags "-s -w ${LDFLAGS}" -o $(NAME)
buildw:
go build -a -installsuffix cgo -ldflags "-w ${LDFLAGS}" -o $(NAME).exe ./*.go
docker:
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest
docker push $(IMAGE_NAME):$(IMAGE_TAG)
docker push $(IMAGE_NAME):latest
run_api:
x-gateway --registry=$(registry) --transport=$(transport) api
run_web:
x-gateway --registry=$(registry) --transport=$(transport) web
.PHONY: run_web run_api buildw build clean vet test docker