I have an app that uses mysql database. The database used by the app is also in Google Cloud. I have a Google Cloud Build task that listen to pushes in a specific branch and will update the app but I have issue automating the db update procedure. If the db update procedure is excluded the app will be built and deployed successfully and works. I have tried to find a solution but wasn't able to (it seems I always seems to struggle to find all the info I need related to GPC and AWS).
I have tried to attach the update script to the composer
post-install-cmd
event but I got "build": Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in
. The connection to the db can't be established. This indicates that the composer install
is executed in a different environment.
The other option that I consider is to add additional steps to the Cloud Build procedure to execute composer install
and after this execute the db update script. The question is will this work or again I will hit a dead end?
I saw multiple posts downloading cloud_sql_proxy
or using gcr.io/google-appengine/exec-wrapper
but this will mean that I will need different configuration.
What is the best practice to update the db when building and deploying to Google App Engine? Any suggestions or refers to documentation, tutorials and discussions would be helpful.