This is the most straightforward way I’ve found to get Ghost running on dokku-alt. Why dokku-alt over dokku? Dokku-alt has native support for Dockerfiles and it comes packaged with a good set of default plugins. It’s a great way to host all of your projects (Ghost included) without having to perform a bunch of technical acrobatics.
The snippets below assume that a host is set up in .ssh/config named “dokku”. For example:
Host dokku HostName 0.0.0.0 # server ip User dokku IdentityFile ~/.ssh/id_rsa
I’ve found that a 2GB DigitalOcean “droplet” is sufficient for hosting a handful of sites. Dokku-alt assumes Ubuntu 14.04 LTS, and you’re best starting out with a fresh server. You may want to add some swap space.
Follow the instructions on dokku-alt’s github page. It’s basically just pasting a line while logged in as root to execute a bootstrap script, and then visiting a temporary configuration website which the bootstrap script starts.
The Dockerfile Project has a simple Dockerfile for Ghost. Clone it, set up the git remote, and push to your dokku instance:
git clone firstname.lastname@example.org:dockerfile/ghost.git cd ghost git remote add dokku dokku:blog git push dokku master
You should see the message “No external HTTP port published” towards the bottom of the output from the git push. This is because the container image exposes Ghost on port 2638, but dokku-alt only sets up ngnix virtual hosts / proxies when it sees the container exposing one of ports 80, 8080 or 5000.
Run Gost on Port 8080
Get a copy of the container’s /ghost/config.js:
ssh dokku exec blog cat /ghost/config.js > config.js
Edit the file and change the port in the production section from 2638 to 8080.
Next, add the following line to the Dockerfile at the bottom of the “Add files” section. This copies your modified config.js to the container:
ADD config.js /ghost/
Finally, change the last line to expose port 8080 instead of 2368:
Commit your changes, push to the dokku repo, and Ghost should be up and running.
There is one final problem. Any time you push changes to the dokku repo, dokku rebuilds your container and consequently overwrites your SQLite3 database.
The fix is to create a data volume such that the /ghost-override/ directory (where the database is stored) persists as your container is rebuilt:
ssh dokku volume:create ghost_override /ghost-override ssh dokku volume:link blog ghost_override
With that, you should have a clean Ghost installation all ready to use.