-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
84 lines (68 loc) · 2.06 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/make
# include envfile
# export $(shell sed 's/=.*//' envfile)
SHELL = /bin/bash
working_dir = $(shell pwd)
build_host = $(shell hostname)
build_time = $(shell date +'%FT%T.%N%:z')
git_repository = $(shell git config --get remote.origin.url)
git_branch = $(shell git rev-parse --abbrev-ref HEAD)
git_commit_id = $(shell git rev-parse --verify HEAD)
git_commit_time = $(shell git log -1 --format="%at" | xargs -I{} date -d @{} +%FT%T%:z)
#### go
check:
command -v go
command -v git
command -v yq
command -v swag
command -v docker
command -v migrate
command -v protoc
command -v protoc-gen-go
command -v protoc-gen-go-grpc
#cache:
# go mod vendor
# mkdir -p cache.local
# mv vendor cache.local/
lint:
go mod tidy
if [ -d vendor ]; then go mod vendor; fi
go fmt ./...
go vet ./...
app_name=swagger bash bin/swagger-go/swag.sh false > /dev/null
build:
target_name=main ./deploy/go_build.sh
ls -al target
release:
release=true ./deploy/go_build.sh
ls -al target
run-api:
target_name=main ./deploy/go_build.sh
./target/main api --config=configs/local.yaml \
-http.addr=:9011 -internal.addr=:9019 -grpc.addr=:9021
run-crons:
target_name=main ./deploy/go_build.sh
./target/main crons --config=configs/crons.yaml
#### swagger
build-swag:
@if [ ! -d "bin/swagger-go" ]; then \
git clone git@github.com:d2jvkpn/swagger-go.git /tmp/swagger-go; \
mkdir -p bin; \
rsync -arvP --exclude .git /tmp/swagger-go ./bin/; \
fi
app_name=swagger bash bin/swagger-go/swag.sh true > /dev/null
ls -al target
run-swag:
app_name=swagger bash bin/swagger-go/swag.sh true > /dev/null
./target/swagger -swagger.title "go backend" \
-config=configs/swagger.yaml -http.addr=:9017
#### image, image-api-dev
image-local:
region=cn DOCKER_Pull=false DOCKER_Push=false DOCKER_Tag=local GIT_Pull=false \
bash deploy/build.sh dev
image-dev:
region=cn DOCKER_Pull=false DOCKER_Tag=dev bash deploy/build.sh dev
image-test:
region=cn DOCKER_Pull=false DOCKER_Tag=test bash deploy/build.sh test
image-main:
region=cn DOCKER_Pull=false DOCKER_Tag=main bash deploy/build.sh main