-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (40 loc) · 1.19 KB
/
Makefile
File metadata and controls
54 lines (40 loc) · 1.19 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
APP ?= roc
PWD := $(shell pwd)
GO ?= go
# GO='GOOS=windows GOARCH=386 go'
VERSION ?= $(shell git describe --tags | sed 's/\(.*\)-.*/\1/')
GIT_COMMIT = $(shell git rev-parse --short HEAD || echo unsupported)
GO_VERSION = $(shell go version)
APP_VERSION = $(shell git describe --tags --abbrev=0)
BUILD_AT = $(shell date "+%Y-%m-%dT%H:%M:%S")
TIMESTAMP := $(shell date +%s)
IMAGE_NAME ?= ${APP}
IMAGE_TAG = ${VERSION}_${GIT_COMMIT}
IMAGE ?= ${IMAGE_NAME}:${IMAGE_TAG}
ver:
@echo "Version: " $(VERSION)
@echo "Major: " $(APP_VERSION)
@echo "Git commit:" $(GIT_COMMIT)
@echo "Go version:" $(GO_VERSION)
@echo "OS env: " $(shell go env GOOS)-$(shell go env GOARCH)
@echo "Build time:" $(BUILD_AT)
image-tag:
@echo ${IMAGE_TAG}
run: local
./bundles/$(APP) -c ${CONFIG_PATH}
local:
$(GO) build -v -o bundles/$(APP) .
linux:
GOOS=linux GOARCH=amd64 $(GO) build -v -o bundles/$(APP)-linux .
test:
$(GO) test -v ./...
test-indocker:
docker run --rm -i \
-v ${PWD}:/go/src/${PKGDIR} \
-w /go/src/${PKGDIR} \
registry.cn-beijing.aliyuncs.com/wa/hub:golang_1.21 make test
build-image:
docker build -t ${IMAGE} .
push-image: build-image push-image-exist
push-image-exist:
docker push ${IMAGE}