-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.mk
56 lines (47 loc) · 1.45 KB
/
deploy.mk
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
PROJECT_ID=jpn-ifc-bc-api
SERVICE_NAME=japan-ifc-building-confirmation-api
REGION=asia-northeast1
SA_NAME=jpn-ifc-bc-api-identity
.PHONY: help
help:
cat ./Makefile
.PHONY: auth
auth:
gcloud components update
gcloud auth login
gcloud auth configure-docker
# gcloudのconfigの設定
.PHONY: gcloud/set/config
gcloud/set/config:
gcloud config set project $(PROJECT_ID)
gcloud config set run/region $(REGION)
# gcloudのservice accountの作成
.PHONY: gcloud/create/sa
gcloud/create/sa:
gcloud iam service-accounts create ${SA_NAME}
# 本番用のimageをビルド
.PHONY: build/prod
build/prod:
docker build -t asia.gcr.io/${PROJECT_ID}/${SERVICE_NAME}-image:${TAG} .
# GCRにimageをデプロイ
.PHONY: gcr/deploy
gcr/deploy:
docker push asia.gcr.io/${PROJECT_ID}/${SERVICE_NAME}-image:${TAG}
# GCRからimageを削除
.PHONY: __gcr/delete
__gcr/delete:
gcloud container images delete asia.gcr.io/${PROJECT_ID}/${SERVICE_NAME}-image:${TAG}
# CCRのimageをCloud Runにデプロイ
.PHONY: cloud-run/deploy
cloud-run/deploy:
gcloud run deploy ${SERVICE_NAME} \
--image asia.gcr.io/${PROJECT_ID}/${SERVICE_NAME}-image:${TAG} \
--region ${REGION} \
--no-allow-unauthenticated \
--service-account ${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com \
.PHONY: deploy/all
deploy/all:
$(MAKE) gcloud/set/config -f deploy.mk
$(MAKE) build/prod TAG=$(TAG) -f deploy.mk
$(MAKE) gcr/deploy TAG=$(TAG) -f deploy.mk
$(MAKE) cloud-run/deploy TAG=$(TAG) -f deploy.mk