Issues encountered while deploying Ghost on Google Cloud Run

config.production.json

{
“url”: “http://localhost:2368”,
“server”: {
“port”: 2368,
“host”: “0.0.0.0”
},
“database”: {
“client”: “mysql”,
“connection”: {
“host”: “30.180.100.40”,
“user”: “blog”,
“password”: “password”,
“database”: “ghost”,
“socketPath”: “/cloudsql/main-project:us-central1:my-sql”
}
},
“mail”: {
“transport”: “Direct”
},
“logging”: {
“transports”: [
“file”,
“stdout”
]
},
“process”: “systemd”,
“paths”: {
“contentPath”: “/var/lib/ghost/content”
},
“storage”: {
“active”: “gcloud”,
“gcloud”: {
“projectId”: “main-project”,
“key”: “/var/lib/ghost/key.json”,
“bucket”: “ghost-blogs”
}
}
}

dockerfile

FROM ghost:latest
RUN mkdir /var/lib/ghost/temp
COPY key.json /var/lib/ghost

ENV HOST 0.0.0.0
RUN npm install --save ghost-google-cloud-storage
COPY config.production.json /var/lib/ghost/config.production.json

RUN mkdir -p /var/lib/ghost/versions/5.82.2/core/server/adapters/storage/gcloud
&& echo “‘use strict’;” > /var/lib/ghost/versions/5.82.2/core/server/adapters/storage/gcloud/index.js
&& echo “module.exports = require(‘ghost-google-cloud-storage’);” >> /var/lib/ghost/versions/5.82.2/core/server/adapters/storage/gcloud/index.js

EXPOSE 2368

Topic

I am running ghost in cloud run by using Ghost-Cloud-Storage adapter(Persistent Storage for images, theme) and MySQL for database. For that i am using above docker file and config.production.json files
I am facing some issues

  1. Initially, Ghost works fine, but after some time, it starts returning a 503 error. Interestingly, it resolves automatically and starts working again, this cycle is repeating.
  2. While I can successfully upload images and store them in a Google Cloud Storage (GCS) bucket, the images uploaded to Ghost are displaying as broken images getting 403 forbidden error.
  3. Although I’m able to upload zip files for themes, they are not being stored in the GCS bucket.

Looks like ghost won´t work with cloud run, because gcp shut down cloud run instances when traffic is low, which means the next time it recieve a request it will start the docker container, and ghost image needs too much time to setup everything before it can start accepting requests again
Bad design unfortunately