-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
36 lines (27 loc) · 1.39 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
## $ make buildgcf func=<function> project_id=<project_id> region=<region> env_vars=<VAR1=value1,VAR2=value2>
buildgcf:
@-gcloud config set project $(project_id)
@-$(eval SUBF := $(shell echo $(func)| tr -d '-'))
@-cd $(func)/$(SUBF) && go mod vendor && gcloud functions deploy $(func) --entry-point=Serve --runtime=go113 --trigger-http --set-env-vars "PROJECT_ID=$(project_id),REGION=$(region),$(env_vars)" --memory 128M --quiet
## $ make buildgcr func=<function> project_id=<project_id> registry=<registry> region=<region> env_vars=<VAR1=value1,VAR2=value2>
buildgcr:
@-faas-cli build --filter $(func)
@-$(eval IMAGE := $(shell cat stack.yml| grep $(func) | grep image | awk '{print $$2}'))
@-$(eval IMAGE_NAME := $(shell echo "$(IMAGE)" | cut -d'/' -f2-))
@-docker tag $(IMAGE) $(registry)/$(project_id)/$(IMAGE_NAME)
@-docker push $(registry)/$(project_id)/$(IMAGE_NAME)
@-gcloud run deploy $(func) --image $(registry)/$(project_id)/$(IMAGE_NAME) --platform managed --memory 128M --region $(region) --set-env-vars "$(env_vars)" --quiet
## $ make faasdelete func=<function>
faasdelete:
@-faas-cli remove --filter $(func)
## $ make faasup func=<function>
faasup: faasdelete $(func)
@-faas-cli up --filter $(func)
.PHONY: help
help: Makefile
@echo
@echo " usage: make <command> <args>"
@echo " "
@echo " commands available:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ \n\t/'
@echo