我正在尝试在Cloud run中连接Cloud sql。相同的应用程序可以与Google应用程序引擎一起很好地工作。但是云运行会导致连接超时错误。
"unhandled error Error: Timeout in connecting after 5000 ms"
我的ENV变量
PG_DB_HOST='/cloudsql/zoftdesk:europe-west2:zoftdesk'
并且我在App Engine灵活环境中使用相同的env变量,并且一切正常 而我的Dockerfile是
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./
COPY yarn.lock ./
RUN yarn install
COPY . .
EXPOSE 8080
CMD [ "yarn", "start" ]
我的cloudbuild.yaml文件是
steps:
# Decrypt the env file
- name: gcr.io/cloud-builders/gcloud
args:
- kms
- decrypt
- --ciphertext-file=.env.enc
- --plaintext-file=.env
- --location=global
- --keyring=birdie
- --key=birdie-backend
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/birdie/birdie-api', '.']
# Push the container image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/birdie/birdie-api']
# Deploy container image to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'birdie-api'
- '--image'
- 'gcr.io/$PROJECT_ID/birdie/birdie-api'
- '--region'
- 'europe-west2'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
- '--add-cloudsql-instances'
- 'zoftdesk:europe-west2:zoftdesk'
images:
- 'gcr.io/$PROJECT_ID/birdie/birdie-api'