docker-如何在 Github Actions 中指定 Google Cloud Run 元数据?
发布时间:2022-07-25 01:35:30 170
相关标签: # nginx
我有一个 Github Action,它构建一个 docker 映像,然后将其上传到 Container Registry。接下来,我想将此容器部署到具有最小和最大实例的一些特定设置的 Cloud Run 服务,确保 CPU 始终开启,仅内部入口等。文档说这些设置是使用 metadata 设置的,但没有显示示例. 这个元数据应该采用什么格式?
name: Push code to GCP
on:
push:
branches: [ main ]
jobs:
container-build-push-deploy:
name: Build Container Push to Registry Deploy to Cloud Run
runs-on: ubuntu-latest
env:
IMAGE_NAME: my-image
PROJECT_ID: my-project-123456
REGION: us-central1
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Authenticate With GCP
id: auth
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ env.PROJECT_ID }}
- name: Tag Release
id: increment-git-tag
run: |
bash ./scripts/git_update.sh -v patch
- name: Build Docker Image
run: docker build -t $IMAGE_NAME:latest .
- name: Configure Docker Client
run: |-
gcloud auth configure-docker --quiet
- name: Push Docker Image to Container Registry
env:
GIT_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
run: |-
docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG
docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG
- name: Deploy to Cloud Run
env:
GIT_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
uses: google-github-actions/deploy-cloudrun@v0
with:
service: my-service
image: 'gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.GIT_TAG }}'
region: ${{ env.REGION }}
secrets: |
/app/path/to/my-secret=my-secret:latest
metadata:
min-instances: 1
max-instances: 1
ingress: internal
tag: ${{ env.GIT_TAG }}
no-cpu-throttling: true
command: node
args: |
/app/path/to/main.js
arg-1
显然这是最后一次metadata
件是错误的,因为with
应该是字符串的键值对。这里的正确格式是什么?
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报