The setup process for the ghost blogging platform recently changed for the v1.x.x series and as such some of the guides on installing ghost with dokku no longer work.

This is how I deployed ghost v1.5.0 to my dokku instance (0.10.3) using dokku's docker deploy method.

This will mainly involve setting up a simple Dockerfile and copying a config into the deployed container.

Note This is for a ghost blog that uses the default sqlite3 db rather than MySQL. I'm still trying to figure that one out.

Requirements

This assumes you've already set up dokku and are running at least 0.10.x.

Dokku

First you will need to create the app on dokku.

dokku apps:create APP_NAME

If you want your blog to be hosted at a subdomain like myblog.domain.example, substitute APP_NAME above with the subdomain (e.g. myblog). If you want it at the root, like domain.example, APP_NAME is domain.example.

Git

Back on your local machine, we'll need to set up a git directory.

Create a folder to put the Dockerfile.

mkdir APP_NAME

Then create a Dockerfile with the contents below:

FROM library/ghost:1

COPY config.production.json /var/lib/ghost

Create a config.production.json within the same directory:

{
  "url": "https://YOURURLHERE/",
  "server": {
    "port": 2368,
    "host": "0.0.0.0"
  },
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/var/lib/ghost/content/data/ghost.db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

Replace the url value to whatever your blog url will be. Make the initial commit.

git init
git add .
git commit -m “Initial”

Add as a remote:

git remote add dokku dokku@YOUR_EMAIL:APP_NAME

Deploy and Set Storage

To deploy:

git push dokku

Once that is done, you'll need to mount a folder to store your blog database (if using sqlite) and other content (e.g. images). Otherwise, if you redeploy, you'll lose all your data.

dokku storage:mount APP_NAME /var/lib/dokku/data/storage/APP_NAME:/var/lib/ghost/content

Add SSL

This is optional but recommended, so that your connection to your ghost admin is secure. Install the letsencrypt plugin:

sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git

Map the correct ports:

dokku proxy:ports-add APP_NAME.YOURDOMAIN http:80:2368

Set the config:

dokku config:set --no-restart blog DOKKU_LETSENCRYPT_EMAIL=YOUREMAIL@WHATEVER

Generate the SSL certificate:

dokku letsencrypt APP_NAME

Enable the letsencrypt job:

dokku letsencrypt:cron-job --add