0

I am using Cloud Run and I want to active the continued implementation whit Github but obviously, I can't upload my env variables so, what can I use

I can't put It when I use "Implement and edit a new version" because it doesn't go to continue, I have to open It click it, and fill the env

I can't use ENV on my Dockerfile because I have to upload it on my Github

I can't use replace it on cloud Build because I am using a Dockerfile and this option is only for cloudbuild.yml (and I don't know how to create it I only know docker :)

Maybe I can edit the yalm on Cloud run I I am not sure if that is a good option

Maybe I can pass if I use gcloud build but I have to click on "Implement and edit a new version" and It is not continuous implementation

My Dockerfile if you want to help me to transform it on a cloudbuild.yml

FROM node:15

WORKDIR /app

COPY package*.json ./

ENV ENV production

ENV PORT 3000

ENV API_URL https://api.mysite.com

RUN npm install --only=production

COPY . .

RUN npm run build

CMD ["npm", "start"]

4

2 回答 2

1

谷歌文档上,我找到了如何创建 cloudbuild.yalm 以进行持续集成

 steps:
 # Build the container image
 - name: 'gcr.io/cloud-builders/docker'
   args: ['build', '-t', 'gcr.io/$PROJECT_ID/api:$COMMIT_SHA', '.']
 # Push the container image to Container Registry
 - name: 'gcr.io/cloud-builders/docker'
   args: ['push', 'gcr.io/$PROJECT_ID/api:$COMMIT_SHA']
 # Deploy container image to Cloud Run
 - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
   entrypoint: gcloud
   args:
   - 'run'
   - 'deploy'
   - 'api'
   - '--image'
   - 'gcr.io/$PROJECT_ID/api:$COMMIT_SHA'
   - '--region'
   - 'us-east1'
   - '--platform'
   - 'managed'
 images:
 - 'gcr.io/$PROJECT_ID/api:$COMMIT_SHA'

您必须为您的服务名称更改 API

之后,我穿上“实施和编辑新版本”并放环境变量

并且所有连续实现都将具有我在实现新版本时放置的相同环境变量。

于 2021-08-02T22:57:15.630 回答
0

您没有将任何环境变量传递给服务。

gcloud beta run deploy --help检查--set-env-vars.

- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
   entrypoint: gcloud
   args:
   - 'run'
   - 'deploy'
   - 'api'
   - '--image'
   - 'gcr.io/$PROJECT_ID/api:$COMMIT_SHA'
   - '--region'
   - 'us-east1'
   - '--platform'
   - 'managed'
   - '--set-env-vars'
   - 'API_URL=${_API_URL}'

You can use substitutions in the build trigger: https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values
于 2021-08-05T11:58:32.980 回答