這裡我們使用的是 GCP 的 Cloud Build 服務,因為 staging 環境跟 production 環境要執行的步驟稍微有一些差異,所以我們把 config 分開寫。
build-arg
cache
cache-dir
cache-ttl
destination
gcr.io/$PROJECT_ID/auth-server:ci-$_NODE_ENV-$SHORT_SHA
steps:
- name: node:12.18.3
id: yarn-install
entrypoint: yarn
args: ["install"]
- name: node:12.18.3
id: auth-test
env:
- "NEW_RELIC_NO_CONFIG_FILE=true"
- "NEW_RELIC_ENABLED=false"
entrypoint: npm
args: ["run", "test"]
dir: "packages/auth-server"
- name: "gcr.io/kaniko-project/executor:v0.22.0"
id: auth-build
env: ["NODE_ENV=$_NODE_ENV"]
args:
- --dockerfile=docker/auth-server.Dockerfile
- --build-arg=NODE_ENV=$_NODE_ENV
- --destination=gcr.io/$PROJECT_ID/auth-server:ci-$_NODE_ENV-$SHORT_SHA
- --cache=true
- --cache-ttl=6h
- name: "gcr.io/cloud-builders/kubectl"
args:
- set
- image
- deployment
- auth-deployment
- auth-server=gcr.io/$PROJECT_ID/auth-server:ci-$_NODE_ENV-$SHORT_SHA
env:
- "CLOUDSDK_COMPUTE_ZONE=asia-east1-a"
- "CLOUDSDK_CONTAINER_CLUSTER=staging-cluster"