Skip to content

Commit

Permalink
cloud build 設定 refs #21
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrovers committed Mar 7, 2021
1 parent 2ffcb3e commit 2e4b9e5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 33 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:12.20-slim

COPY ./frontend/dist/frontend /dist/frontend

COPY ./frontend/node_modules /node_modules

CMD [ "node", "/dist/frontend/server/main.js" ]
87 changes: 54 additions & 33 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
steps:
- name: gcr.io/cloud-builders/docker
id: cds-emulator
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']
- name: jwilder/dockerize:0.6.1
args: ['dockerize', '-timeout=60s', '-wait=tcp://cds-emulator:8081']
- name: 'golang:1.13-stretch'
id: go-test
entrypoint: 'go'
args: ['test', '-v', './...']
env:
- 'GO111MODULE=on'
- 'DATASTORE_EMULATOR_HOST=cds-emulator:8081'
- 'GOOGLE_CLOUD_PROJECT=unittest'
waitFor: ['cds-emulator']
# angular build
- name: node:12.13
id: npm-ci
- name: node:12.21-slim
id: npm-install
entrypoint: 'npm'
args: ['ci']
dir: 'frontend'
waitFor: ['-']
args:
- ci
dir: frontend
waitFor:
- '-'

# Angular unit test
- name: node:12.13
id: npm-run
id: angular-test
entrypoint: 'npm'
args:
- run
- test
dir: frontend
waitFor:
- npm-install

# Angular + nestjs build
- name: node:12.21-slim
id: angular-with-nest-build
entrypoint: 'npm'
args: ['run', 'build:prod']
dir: 'frontend'
waitFor: ['npm-ci']
# deploy
- name: 'gcr.io/cloud-builders/gcloud'
args:
- 'app'
- 'deploy'
- run
- build:ssr
dir: frontend
waitFor:
- npm-install

# build Docker image with cache
- name: 'gcr.io/kaniko-project/executor:v1.3.0'
id: kaniko
args:
- --destination=asia-northeast1-docker.pkg.dev/$PROJECT_ID/jpsite/$BRANCH_NAME:$COMMIT_SHA
- --cache=true
- --cache-ttl=6h
waitFor:
- angular-test
- angular-with-nest-build

# deploy Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:319.0.0'
entrypoint: 'gcloud'
args:
- run
- deploy
- jpsite
- --region=asia-northeast1
- --platform=managed
- --service-account=jpsite-run@$PROJECT_ID.iam.gserviceaccount.com
- --max-instances=1
- --cpu=1
- --memory=256M
- --concurrency=8
- --image=asia-northeast1-docker.pkg.dev/$PROJECT_ID/jpsite/$BRANCH_NAME:$COMMIT_SHA
waitFor:
- 'go-test'
- 'npm-run'
# for cloud-build-local
- name: gcr.io/cloud-builders/docker
args: ['rm', '--force', 'cds-emulator']
- kaniko

0 comments on commit 2e4b9e5

Please sign in to comment.