-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
84 lines (66 loc) · 2.44 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
REGION = us-central1
ARTIFACT_REPOSITORY_URL_BASE = $(REGION)-docker.pkg.dev/$(PROJECT)/$(REPO)
BUILD := go build
BUILD_ARMV6 := GOOS=linux GOARCH=arm GOARM=6 $(BUILD) -ldflags="-s -w"
BUILD_ARMV7 := GOOS=linux GOARCH=arm GOARM=7 $(BUILD) -ldflags="-s -w"
OUT_DIR := out
MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
all: iotcorelogger lambda readtemp api apiclient
.PHONY: iotcorelogger
iotcorelogger: proto
$(BUILD) -o $(OUT_DIR)/$@ ./cmd/$@
$(BUILD_ARMV7) -o $(OUT_DIR)/armv7/$@ ./cmd/$@
$(BUILD_ARMV6) -o $(OUT_DIR)/armv6/$@ ./cmd/$@
.PHONY: readtemp
readtemp:
$(BUILD) -o $(OUT_DIR)/$@ ./cmd/$@
$(BUILD_ARMV7) -o $(OUT_DIR)/armv7/$@ ./cmd/$@
$(BUILD_ARMV6) -o $(OUT_DIR)/armv6/$@ ./cmd/$@
.PHONY: api
api:
$(BUILD) -o $(OUT_DIR)/$@ ./cmd/$@
.PHONY: lambda
lambda:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags lambda.norpc -o $(OUT_DIR)/bootstrap ./cmd/$@
cd $(OUT_DIR) && zip $@.zip bootstrap
.PHONY: apiclient
apiclient:
$(BUILD) -o $(OUT_DIR)/$@ ./cmd/$@
api-image: check-env
docker build -f MeasurementService.Dockerfile -t $(ARTIFACT_REPOSITORY_URL_BASE)/api .
api-image-remote: check-env
gcloud --project=$(PROJECT) builds submit \
--region=$(REGION) \
--config cloudbuild-api.yaml \
--substitutions=TAG_NAME="$(ARTIFACT_REPOSITORY_URL_BASE)/api"
web-image: check-env
docker build -f Web.Dockerfile -t $(ARTIFACT_REPOSITORY_URL_BASE)/web .
web-image-remote: check-env
gcloud --project=$(PROJECT) builds submit \
--region=$(REGION) \
--config cloudbuild-web.yaml \
--substitutions=TAG_NAME="$(ARTIFACT_REPOSITORY_URL_BASE)/web"
run-web: check-env
docker run -v $(MAKEFILE_DIR)/keys:/keys --env-file env -p 8080:8080 $(ARTIFACT_REPOSITORY_URL_BASE)/web
.PHONY: proto
proto:
# Get protoc from https://github.com/protocolbuffers/protobuf/releases
# Install the Go and Go gRPC plugins like this:
# go install google.golang.org/protobuf/cmd/protoc-gen-go
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
protoc --include_imports --include_source_info \
--descriptor_set_out=measurementpb/measurement.pb.descriptor \
--go_out=module=github.com/mtraver/environmental-sensor:. \
--go-grpc_out=module=github.com/mtraver/environmental-sensor:. \
measurement.proto
protoc --go_out=module=github.com/mtraver/environmental-sensor:. \
configpb/config.proto
check-env:
ifndef PROJECT
$(error PROJECT is undefined)
endif
ifndef REPO
$(error REPO is undefined)
endif
clean:
rm -rf $(OUT_DIR)