-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
54 lines (41 loc) · 1.28 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
# Application Information
GIT_COMMIT=$(shell git rev-parse --verify HEAD)
GIT_TAG ?= "master"
RELEASED_AT=$(shell date +'%y.%m.%d-%H:%M:%S')
IMG=opensourceway/omni-repositiory:$(GIT_COMMIT)
ARCHITECTURE ?= "amd64"
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
all: manager
# Run tests
test: fmt vet swagger-doc
go test ./... -coverprofile cover.out
# Build manager binary
manager: fmt vet swagger-doc
go build -ldflags "-X main.Tag=$(GIT_TAG) -X main.CommitID=$(GIT_COMMIT) -X main.ReleaseAt=$(RELEASED_AT)" -o bin/omni-repositiory main.go
# Run up server
# NOTE(tommylike): do not use go run command for the issue of signal relay issue
run: manager
./bin/omni-repositiory run
# Generate swagger docs
swagger-doc:
swag init
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
# Prepare mysql database
mysql:
./scripts/prepare-database.sh
# Build the docker image
docker-build:
docker build . -t ${IMG} --build-arg GO_ARCHITECTURE=${ARCHITECTURE} --build-arg GIT_TAG=${GIT_TAG} --build-arg GIT_COMMIT=${GIT_COMMIT} --build-arg RELEASED_AT=${RELEASED_AT}
# Push the docker image
docker-push:
docker push ${IMG}