-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
68 lines (51 loc) · 1.87 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
.PHONY: clean prepare api api/client build docker/push docker/build docker/clean run deps
ARCH ?= amd64
GOARCH ?= ${ARCH}
GOARM ?= 7
NAME=ddns
PKG=github.com/muka/${NAME}
GOPKGS=${GOPATH}/src
GOPKGSRC=${GOPKGS}/${PKG}
IMAGE="opny/${NAME}-${ARCH}"
CGO ?= 0
PROTOC := ./data/protoc/bin/protoc \
-I ./data/protoc/include \
-I /usr/local/include \
-I. \
-I ${GOPATH}/src \
-I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
setup: setup/protoc setup/godeps
setup/protoc:
mkdir -p ./data/protoc
cd data/protoc && \
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protoc-3.8.0-linux-x86_64.zip && \
unzip protoc-3.8.0-linux-x86_64.zip && \
rm -f protoc-3.8.0-linux-x86_64.zip
setup/godeps:
go get -u -v ./...
clean:
rm -rf ./build
prepare:
mkdir -p ./build
deps:
go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
api:
${PROTOC} --go_out=google/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. api/coredns.proto
${PROTOC} --go_out=google/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. api/api.proto
${PROTOC} --grpc-gateway_out=logtostderr=true:. api/api.proto
${PROTOC} --swagger_out=logtostderr=true:. api/api.proto
build: prepare api
CGO_ENABLED=${CGO} ARCH=${ARCH} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ./build/${NAME} cli/cli.go
run: api api/client
go run cli/cli.go
docker/build:
docker build . -t ${IMAGE}
docker/push: docker/build
docker push ${IMAGE}
docker/clean:
docker rmi $(docker images | grep ${NAME} | awk '{print $1}')
all: build api/client docker/build