I have a Rails app that should be hosted via Google Cloud App Engine. It has a Postgres database setup. I followed this tutorial: https://cloud.google.com/ruby/rails/using-cloudsql-postgres
I added all my configurations in app.yaml:
entrypoint: bundle exec rackup --port $PORT
env: flex
runtime: ruby
env_variables:
SECRET_KEY_BASE: [SECRET_KEY]
beta_settings:
cloud_sql_instances: [INSTANCE]
and database.yml:
production:
adapter: postgresql
encoding: unicode
pool: 5
timeout: 5000
username: postgres
password: [DB_PASSWORD]
database: [DB_DATABASE]
host: /cloudsql/[INSTANCE]
The Cloud SQL instance is setup correctly as I can connect to it using Cloud SQL proxy: https://cloud.google.com/sql/docs/postgres/connect-admin-proxy
After deployment to App Engine and trying to migrate it gives me the follwoing error:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/cloudsql/[INSTANCE]/.s.PGSQL.5432"?
This also happens with a running proxy locally and trying to
RAILS_ENV=production rake db:create rake db:migrate
I see that /cloudsql folder is missing when I SSH into the App Engine's VM. I double-checked, access rights should be there and Cloud SQL API and Cloud SQL Admin API are enabled. I also noticed that when SSHing into the App Engine's VMs (apparently there are two, I tried both of them) and running ls the directories are completely empty. The deployment worked though as I can access the app but not the controller that require DB connection.
[PROJECT]:[REGION]:[INSTANCE NAME]
? for example tetsingfakeproject:us-central1:testdatabase - Jan Hernandez