-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
72 lines (50 loc) · 1.42 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
GOPATH:=$(shell go env GOPATH)
# ----- Install -----
.PHONY: install
install:
go mod download
# ----- Test -----
BUILDENV := CGO_ENABLED=0
TESTFLAGS := -short -cover -v
SERVICE=fpn-openvpn
.PHONY: test
test:
$(BUILDENV) go test $(TESTFLAGS) ./...
# ----- Protos -----
CONTRACTS_DIR=$(shell pwd)/contracts
GENERATED_BUILD_DIR=$(shell pwd)/generated
protos-clean:
rm -rf $(GENERATED_BUILD_DIR)
protos: protos-clean
mkdir -p $(GENERATED_BUILD_DIR)/vpn
go get github.com/golang/protobuf/protoc-gen-go
protoc \
-I=$(CONTRACTS_DIR)/fpn-contracts/vpn \
--go_out=plugins=grpc:$(GENERATED_BUILD_DIR)/vpn \
$(CONTRACTS_DIR)/fpn-contracts/vpn/*.proto
# ----- Build -----
.PHONY: build
build:
CGO_ENABLED=0 go build -o $(SERVICE)
.PHONY: dev
dev:
go run .
# ----- CI -----
DOCKER_REGISTRY=freemiumvpn
DOCKER_CONTAINER_NAME=$(SERVICE)
DOCKER_REPOSITORY=$(DOCKER_REGISTRY)/$(DOCKER_CONTAINER_NAME)
SHA8=$(shell echo $(GITHUB_SHA) | cut -c1-8)
docker-image:
docker build --rm \
--build-arg SERVICE=$(SERVICE) \
--tag $(DOCKER_REPOSITORY):local .
ci-docker-auth:
@echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
ci-docker-build:
@docker build --rm \
--build-arg SERVICE=$(SERVICE) \
--tag $(DOCKER_REPOSITORY):$(SHA8) \
--tag $(DOCKER_REPOSITORY):latest .
ci-docker-build-push: ci-docker-build
@docker push $(DOCKER_REPOSITORY):$(SHA8)
@docker push $(DOCKER_REPOSITORY):latest