Skip to content

Commit 2e4b9e5

Browse files
committed
cloud build 設定 refs #21
1 parent 2ffcb3e commit 2e4b9e5

File tree

2 files changed

+61
-33
lines changed

2 files changed

+61
-33
lines changed

Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM node:12.20-slim
2+
3+
COPY ./frontend/dist/frontend /dist/frontend
4+
5+
COPY ./frontend/node_modules /node_modules
6+
7+
CMD [ "node", "/dist/frontend/server/main.js" ]

cloudbuild.yaml

+54-33
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,60 @@
11
steps:
2-
- name: gcr.io/cloud-builders/docker
3-
id: cds-emulator
4-
args: ['run', '-d', '--network=cloudbuild', '--name=cds-emulator', 'google/cloud-sdk:248.0.0', 'gcloud', 'beta', 'emulators', 'datastore', 'start', '--host-port=0.0.0.0:8081']
5-
- name: jwilder/dockerize:0.6.1
6-
args: ['dockerize', '-timeout=60s', '-wait=tcp://cds-emulator:8081']
7-
- name: 'golang:1.13-stretch'
8-
id: go-test
9-
entrypoint: 'go'
10-
args: ['test', '-v', './...']
11-
env:
12-
- 'GO111MODULE=on'
13-
- 'DATASTORE_EMULATOR_HOST=cds-emulator:8081'
14-
- 'GOOGLE_CLOUD_PROJECT=unittest'
15-
waitFor: ['cds-emulator']
16-
# angular build
17-
- name: node:12.13
18-
id: npm-ci
2+
- name: node:12.21-slim
3+
id: npm-install
194
entrypoint: 'npm'
20-
args: ['ci']
21-
dir: 'frontend'
22-
waitFor: ['-']
5+
args:
6+
- ci
7+
dir: frontend
8+
waitFor:
9+
- '-'
10+
11+
# Angular unit test
2312
- name: node:12.13
24-
id: npm-run
13+
id: angular-test
14+
entrypoint: 'npm'
15+
args:
16+
- run
17+
- test
18+
dir: frontend
19+
waitFor:
20+
- npm-install
21+
22+
# Angular + nestjs build
23+
- name: node:12.21-slim
24+
id: angular-with-nest-build
2525
entrypoint: 'npm'
26-
args: ['run', 'build:prod']
27-
dir: 'frontend'
28-
waitFor: ['npm-ci']
29-
# deploy
30-
- name: 'gcr.io/cloud-builders/gcloud'
3126
args:
32-
- 'app'
33-
- 'deploy'
27+
- run
28+
- build:ssr
29+
dir: frontend
30+
waitFor:
31+
- npm-install
32+
33+
# build Docker image with cache
34+
- name: 'gcr.io/kaniko-project/executor:v1.3.0'
35+
id: kaniko
36+
args:
37+
- --destination=asia-northeast1-docker.pkg.dev/$PROJECT_ID/jpsite/$BRANCH_NAME:$COMMIT_SHA
38+
- --cache=true
39+
- --cache-ttl=6h
40+
waitFor:
41+
- angular-test
42+
- angular-with-nest-build
43+
44+
# deploy Cloud Run
45+
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:319.0.0'
46+
entrypoint: 'gcloud'
47+
args:
48+
- run
49+
- deploy
50+
- jpsite
51+
- --region=asia-northeast1
52+
- --platform=managed
53+
- --service-account=jpsite-run@$PROJECT_ID.iam.gserviceaccount.com
54+
- --max-instances=1
55+
- --cpu=1
56+
- --memory=256M
57+
- --concurrency=8
58+
- --image=asia-northeast1-docker.pkg.dev/$PROJECT_ID/jpsite/$BRANCH_NAME:$COMMIT_SHA
3459
waitFor:
35-
- 'go-test'
36-
- 'npm-run'
37-
# for cloud-build-local
38-
- name: gcr.io/cloud-builders/docker
39-
args: ['rm', '--force', 'cds-emulator']
60+
- kaniko

0 commit comments

Comments
 (0)