The documentation on GCP suggest that the right way to do is using App Engine/Node -- until you get the step that says
Follow the instructions on the Ghost website to install Ghost as an NPM Module.
Well, the instructions on the Ghost website say don't install Ghost as an NPM Module. It's not supported.
OK, how about CloudRun? I found this extremely promising sample on Git. Only downside is it uses an internal SqlLite database, and I need to connect to an existing MySQL database hosted on GCP.
Apparently, there is some sort of issue with hooking up to a MySQL database hosted on GCP over TCP. Dunno why, but there is a proxy you run locally instead. I can run Ghost from the command line, like this:
ghost config --ip 0.0.0.0 --port 8080 --no-prompt --url http://localhost:8080 --db mysql --dbhost localhost --dbuser ghost_service --dbpass <pass> --dbname darkstore_blog_db
ghost start
And it seems to work.
However, with the same arguments in the Dockerfile, I get
app_1 | [2020-02-01 02:15:39] ERROR Invalid database host.
app_1 |
app_1 | Invalid database host.
app_1 |
app_1 | "Please double check your database config."
app_1 |
app_1 | Error ID:
app_1 | 500
Now that's not absurd: the Docker container is a VM-like thing, with its own definition of "localhost". The documentation suggests using "host.docker.internal" instead. Nope, same result.
OK, fine, I don't need to run it on a local Docker container. The problem is, if it is running under CloudRun, it can't use the proxy, of course. I am supposed to set a configuration value called "socketPath" to the value /cloudsql/mycompany-1943107437902:us-west1:mycompany-blog-db
, of course.
But there is no way to set socketPath! That's not an argument to ghost config and I don't see a way to supply a configuration file.
So I'm stymied. I'm a little annoyed at
- the database people for thinking it's legitimate to require four or five separate arguments -- arguments that are not consistent across different DBMSs -- to open a connection
- the Ghost people, for not supporting what looks to me like an obvious use case out of the box
- the GCP people, just because they are getting on my nerves
But mostly, I'd like to get past this. Someone must have gotten this working.