1

Hi I am trying to make a php artisan migrate with my script with a cloud sql proxy connection. The sql proxy connection working fine but when it launch my command it fail with the error

---------- CONNECT CLOUDSQL ----------
cloud_sql_proxy is running.
Connections: ****:europe-west1:***-bdd.
---------- EXECUTE COMMAND ----------
/var/www/scripts-cloud/migrate.sh
 Illuminate\Database\QueryException
 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for /cloudsql/*** failed: Name or service not known (SQL: select * from information_schema.tables where table_schema = scorecard and table_name = migrations and table_type = 'BASE TABLE')

here my code

 - name: "gcr.io/google-appengine/exec-wrapper"
 entrypoint: 'bash'
 args:
 - -c
 - |
 /buildstep/execute.sh \
 -i europe-west1-docker.pkg.dev/$PROJECT_ID/$$SERVICE_NAME/api \
 -e DB_CONNECTION=mysql \
 -e DB_SOCKET=$$DB_HOST \
 -e CLOUD_SQL_CONNECTION_NAME=$$PROJECT_ID:$$PROJECT_REGION:$$PROJECT_INSTANCE \
 -e DB_DATABASE=$$DB_DATABASE \
 -e DB_USERNAME=$$DB_USERNAME \
 -e DB_PASSWORD=$$DB_PASSWORD \
 -e EMAIL_SUPER_ADMIN=$$EMAIL_SUPER_ADMIN \
 -e PWD_SUPER_ADMIN=$$PWD_SUPER_ADMIN \
 -s $$PROJECT_ID:$$PROJECT_REGION:$$PROJECT_INSTANCE \
 /var/www/scripts-cloud/migrate.sh
 secretEnv: ['DB_PASSWORD', 'DB_DATABASE', 'DB_USERNAME', 'DB_HOST', 'PROJECT_ID', 'PROJECT_REGION', 'PROJECT_INSTANCE', 'SERVICE_NAME', 'EMAIL_SUPER_ADMIN', 'PWD_SUPER_ADMIN']

If I launch a connection manually with a command cloud proxy

./cloud-sql-proxy --port 3307 ****:europe-west1:***-bdd

I can connect and use the bdd locally and launching everything I want

Did I forget something?

THanks

I reverify all the code, replace manually, launching locally

asked Feb 20, 2024 at 10:25
3
  • 1
    Ok i fail cause my .env doesn't contain DB_SOCKET value ;) Commented Feb 20, 2024 at 12:51
  • Please post your answer for the benefit of others. Commented Feb 23, 2024 at 19:43
  • 1
    I post it just on the first comment :) It was a variable DB_SOCKET which was missing :) Commented Feb 28, 2024 at 15:09

1 Answer 1

1

Sharing this as a community wiki for the benefit of others

As mentioned by @shinzo94

My .env doesn't contain DB_SOCKET value

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.