Deploy Ghost to Google App Engine Flexible Environment
The Google App Engine is a great way to host and deploy Software for the web without hassle. Thats the reason why i host my own stuff on the GAE. And here i want to tell you how i deployed ghost on the GAE.
To run ghost on the GAE you need to install it via npm. To do so you can install it by npm i ghost --save or add this package.json and type npm install.
After that you are prepared to start with mysql and other stuff, the article has some broken links, but the work for mysql and deploys works fine, this tutorial is for an older version 1.x of ghost ;-)
On the linke above you will find a good entry point how to run ghost on the GAE. The howto is missing some little things, at first you have to install and run ghost as npm module. That means that you dont can run it with the ghost-cli. You need to create a simple wrapper to do so.
With these two files you can start really fast with the GAE and ghost. To handle the picture uploads on ghost i use also the google cloud storage.
To solve this i use the Google Cloud storage adapter, but the main issue was that it wouldnt work with the current ghost version, for that i forked it and upgraded it for the current ghost version.
npm i ghost-google-cloud-storage-new --save
After that you need to check your configs, production and development and add the storage config.
"storage": {
"active": "gcloud",
"gcloud": {
"projectId": "Your_project_id",
"key": "Your_key_path",
"bucket": "Your_bucket_name",
"insecure": false,
"maxAge": "2678400"
}
}
I dont prefer to use your own domain, instead you can use the bucket url from google, then the storage adapter will send everything with HTTPS and thats state of the art.
After that you can deploy your application and the uploads are stored on the google cloud storage.
Congratulations, now you have deployed ghost on the Google App Engine flex environment.
On Pro tip for debugging, if you want to debug your running GAE flex instance, thats no problem. Because the GAE flex is running inside a docker container.
To enable debugging and connecting to your container you need to go to the App Engine -> Instances Dashboard
![](https://storage.googleapis.com/ghostcmsyakisch/2018/12/gaeDebugFlexSSH.png)
And click on the ssh, select the method you prefer. Browser window or glcoud command to connect from your local terminal.
After your connected via ssh to your instance you can discover the different containers with
docker ps
Then you see a list with docker containers running inside the instance. To connect and debug your running application type
docker exec -it gaeapp bash
gaeapp is your application name. This command will attach you to the running container and starting bash. So after typing this you are connected to the docker container with bash.