-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMakefile
45 lines (35 loc) · 1 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
PROJECT_ROOT?=$(shell pwd)
PROJECT_PKG?=evhub
TARGET_PKG=$(PROJECT_PKG)/cmd
IMAGE_PREFIX?=evhub
TARGET_IMAGE=$(IMAGE_PREFIX)/$(TARGET):$(VERSION)
lint:
build/lint.sh
fmt:
gofmt -l -s -w .
goimports -w .
proto:
build/generate-protobuf.sh
build:
make proto
go build -o ./bin/$(TARGET) ./cmd/$(TARGET)
binary:
CGO_ENABLED=0 go build \
-o /usr/local/go/src/$(PROJECT_PKG)/bin/$(TARGET) /usr/local/go/src/$(TARGET_PKG)/$(TARGET)
target:
mkdir -p $(PROJECT_ROOT)/bin
docker run --rm -i -v $(PROJECT_ROOT):/usr/local/go/src/$(PROJECT_PKG) \
-w /usr/local/go/src/$(PROJECT_PKG) golang:1.17.12 \
make binary TARGET=$(TARGET)
image:
make target TARGET=$(TARGET) && \
temp=`mktemp -d` && \
cp -r $(PROJECT_ROOT)/build/images/$(TARGET)/ $$temp/$(TARGET)/ && cp -r $(PROJECT_ROOT)/bin/ $$temp/$(TARGET)/bin/ && \
docker build -t $(TARGET_IMAGE) $$temp/$(TARGET) && \
rm -r $$temp
rm -r ./bin
start:
build/docker-compose/start.sh
stop:
build/docker-compose/stop.sh
.PHONY: image target clean binary