It's really hard to motivate myself to create content when every article requires digging into code to create a custom page. That's why I decided to self host Ghost, a popular CMS. Here is a step by step guide in case you want to do the same.

Follow instructions to install Dokku before starting this tutorial.

  1. Create a new app
dokku apps:create ghost
  1. Install and setup the Dokku MySQL plugin
# Install plugin
dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql

# Create a new database 
dokku mysql:create ghost-db

# Link it to the app 
dokku mysql:link ghost-db ghost
  1. Add the database config
    database__connection__password should be retreived from the output of the previous step.
dokku config:set --no-restart ghost database__client=mysql \
database__connection__host=dokku-mysql-ghost-db \ 
database__connection__user=mysql \
database__connection__password=<password> \
database__connection__database=ghost_db
  1. Mount storage
# Create the directory
mkdir -p /var/lib/dokku/storage/ghost

# Mount
dokku storage:mount ghost /var/lib/dokku/data/storage/ghost:/var/lib/ghost/content

5 Pull and connect the docker image

# Pull
docker pull ghost:latest

# Tag
docker tag ghost:latest dokku/ghost:latest
  1. Deploy the app
dokku tags:deploy ghost latest
  1. Update app ports
dokku proxy:ports-add ghost http:80:2368
  1. Connect a domain
    Your dns settings should include an A record pointing to your server for this to work
# set dokku domain
dokku domains:set ghost example.com

# update ghost url
dokku config:set ghost url=http://example.com
  1. Allow large files
mkdir -p /home/dokku/ghost/nginx.conf.d

echo 'client_max_body_size 50M;' > /home/dokku/ghost/nginx.conf.d/upload.conf
  1. Enable HTTPS
# Install the Dokku Letsencrypt plugin
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git

# Add your email to the configuration
dokku config:set --global DOKKU_LETSENCRYPT_EMAIL=your@email.tld

# Encrypt
dokku letsencrypt ghost

Thats it! Now visit /ghost on your domain to access the Ghost console and start blogging.


I used a combination of various guides to get to this particular configuration. Check them out here and here.