I want to configure CI/CD
from Cloud Repositories
that builds my CMS
(Directus) when I push to main repository.
In the build-time, the project needs to access Cloud SQL
. But I get this error:
I tried this database configuration with gcloud app deploy
and it connects Cloud SQL
and runs.
cloudbuild.yaml
(It crashes at second step, so I didn't add other steps for simplicity):
steps:
- name: node:16
entrypoint: npm
args: ['install']
dir: cms
- name: node:16
entrypoint: npm
args: ['run', 'start']
dir: cms
env:
- 'NODE_ENV=PRODUCTION'
- 'EXTENSIONS_PATH="./extensions"'
- 'DB_CLIENT=pg'
- 'DB_HOST=/cloudsql/XXX:europe-west1:XXX'
- 'DB_PORT="5432"'
- 'DB_DATABASE="XXXXX"'
- 'DB_USER="postgres"'
- 'DB_PASSWORD="XXXXXX"'
- 'KEY="XXXXXXXX"'
- 'SECRET="XXXXXXXXXXXX"'
Node-pg
(node library) adds /.s.PGSQL.5432
at the end automatically. That's why it is not written in DB_HOST
.
How can I solve this error? I read so many answers in Stackoverflow but none of them helped me. I found this article but I didn't fully understand how to implement it in my case ( https://cloud.google.com/sql/docs/postgres/connect-build ).
Without your full Cloud Build yaml, it's hard to say for sure - but, it looks like you aren't following the steps in the documentation correctly .
Roughly what you should be doing is:
cloud_sql_proxy
into your container spaceI don't see your yaml describing the proxy at all.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.