Skip to content

Instantly share code, notes, and snippets.

@patr1ck
Last active January 21, 2024 05:57
Show Gist options
  • Save patr1ck/4bd1dac444077bfe551a6851d825b05d to your computer and use it in GitHub Desktop.
Save patr1ck/4bd1dac444077bfe551a6851d825b05d to your computer and use it in GitHub Desktop.
Self-hosting Ghost on Dokku

Ghost on Dokku

Last updated: Jan 20 2024

This guide assumes you already have a functioning Dokku installation, along with the Dokku MySQL plugin and the Dokku letsencrypt plugin. It also assumes you want to use ghost at the root of a domain.

Create your app

dokku apps:create ghostblog.com

Create the DB and link it to the app

dokku mysql:create ghostblog
dokku mysql:link ghostblog ghostblog.com

Note that the service name is ghostblog, the app name is ghostblog.com

Grab the database login details and set them as config variables

dokku config:show ghostblog.com

This will return something like mysql://mysql:[password]@dokku-mysql-ghost:3306/ghostblog, which you can break apart like so:

dokku config:set ghostblog.com \
  database__connection__host=dokku-mysql-ghostblog \
  database__connection__user=mysql \
  database__connection__password=[password] \
  database__connection__database=ghostblog

Set the ghost environment to production

dokku config:set ghostblog.com NODE_ENV=production url=https://ghostblog.com database__client=mysql

Set the nginx proxy to handle large uploads (optional, but you probably want this)

dokku nginx:set ghostblog.com client-max-body-size 50m
dokku proxy:build-config ghostblog.com

Create the persistant storage container

mkdir -p /root/ghostblog.com/content
dokku storage:mount ghostblog.com /root/ghostblog.com/content:/var/lib/ghost/content

Deploy Ghost from the docker image

dokku git:from-image ghostblog.com ghost:latest

Set up the proxy so you can access it

dokku ports:set ghostblog.com http:80:2368

Enable letsencrypt

dokku letsencrypt:enable ghostblog.com

Enable email sending

This assumes you're using sendgrid, but you can configure your own SMTP options below:

dokku config:set ghostblog.com \
  mail__transport=SMTP \
  mail__from="[email protected]" \
  mail__options__service=SMTP \
  mail__options__host=smtp.sendgrid.net \
  mail__options__port=587 \
  mail__options__auth__user=apikey \
  mail__options__auth__pass=[password]

Setup the blog on the web

Navigate to https://ghostblog.com/ghost and follow the steps.

Updating Ghost

docker image pull ghost
dokku ps:rebuild ghostblog.com

Some helpful links:

Ghost Docker image: https://hub.docker.com/_/ghost/

Ghost Email Configuration: https://ghost.org/docs/config/#mail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment