This is my blog that uses WriteFreely deployed to Dokku.
Here's a blog post describing how I set up my entire website with dokku: How I Created johanv.xyz. I have duplicated the instructions for just the blog subdomain here, and this version will be the one I keep updated. Note: this guide uses johanv.xyz as the domain name, so when following the instructions, just substitute your domain name wherever you see it. Also, let me know if you find a mistake in this documentation.
I'm using a DigitalOcean droplet for $5 a month, choosing the operating system image with dokku pre-installed. However, you can just as easily get a Debian based cloud server from any provider and install it yourself. And you can always self-host by installing Debian on an old computer, connecting it to your router, and port forwarding ports 22, 80, and 443 from the router to the computer. There are pros and cons to each approach, which is beyond the scope of this README -- you can find plenty of info online.
I got johanv.xyz on NameSilo for only a few dollars a year. Then point the domain name to the IP address of your cloud server with a DNS A record. If you are using DigitalOcean, or another provider that can manage DNS records, you can do what I did: point the nameservers of your domain registrar (NameSilo for me) to your cloud provider (DigitalOcean for me). Then the DNS records are managed by DigitalOcean and you can set up the A record there to point to your cloud server.
Based on this guide.
Update and install Docker, Dokku, and dependencies.
ssh [email protected] #replace this with your server's ip address
apt update
apt dist-upgrade
# Install the prerequisites
apt install -qq -y apt-transport-https
# Install Docker
wget -nv -O - https://get.docker.com/ | sh
# Add Dokku apt repository
wget -nv -O - https://packagecloud.io/gpg.key | sudo apt-key add -
export SOURCE="https://packagecloud.io/dokku/dokku/ubuntu/"
echo "deb $SOURCE trusty main" | sudo tee /etc/apt/sources.list.d/dokku.list
apt update -qq
# Install Dokku, when asked, select YES to enable web setup
apt-get install -qq -y dokku
dokku plugin:install-dependencies --core
#OLD: apt install -qq -y dokku herokuish sshcommand plugn
reboot
Complete the following step as soon as possible, or someone else will eventually! :)
Create an ssh key:
ssh-keygen -b 4096
cat ~/.ssh/id_rsa.pub
To execute dokku commands on the server, you will have to first run ssh-add ~/.ssh/id_rsa
locally. You'll have to run this command every time you reboot your local computer.
Go to your domain name in a browser, and you will see a dokku setup page. Copy and paste in the SSH public key (NOT private key) from before. Enter your domain name, and check the box labelled "use virtualhost naming for apps."
I followed this tutorial by Evan Walsh.
git clone https://gitlab.com/johanvandegriff/blog.johanv.xyz.git
You will want to edit config.ini and change the site's name and URL. I set it to a single-user instance, so you may want to change it back to a multi-user setup.
I also used a bash script to patch the docker image, adding a footer with my email address, among other things. You will want to change the email address to your own, or remove it (I don't want to get random emails because you left it as mine. :) The address is obfuscated, so it's kind of awkward to change, but I have published the PHP code I used to generate it. There are tons of other ways to obfuscate email addresses as well.
ssh [email protected] apps:create blog
# Set up persistent storage to preserve the database and keys when rebuilding the app:
ssh [email protected] mkdir -p /var/lib/dokku/data/storage/writefreely/{db,keys}
ssh [email protected] chown -R bin:bin /var/lib/dokku/data/storage/writefreely/
#https://github.com/dokku/dokku/issues/2215
ssh [email protected] storage:mount blog /var/lib/dokku/data/storage/writefreely/keys:/go/keys
ssh [email protected] storage:mount blog /var/lib/dokku/data/storage/writefreely/db:/go/db
ssh [email protected] proxy:ports-set blog http:80:8080
# Push the app to Dokku:
git remote add dokku [email protected]:blog
git push dokku master #this build fails
#Now, the site is visible, but it displays an internal error. Initialize the instance:
ssh [email protected] run blog --help
ssh [email protected] run blog --init-db
ssh [email protected] run blog --gen-keys
# And rebuild the app:
ssh [email protected] ps:rebuild blog
# Set up the blog admin password. Put a real password instead of just "password"
ssh [email protected] run blog -create-admin johanv:password
Enable HTTPS, or your admin password for the blog will be sent in plaintext and would be very easy to steal!
Fortunately, Dokku has a nice plugin that makes this easy:
ssh [email protected] dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
ssh [email protected] letsencrypt:cron-job --add #auto renew certs
Add HTTPS to the blog (replace [email protected] with your actual email):
ssh [email protected] config:set --no-restart blog [email protected]
ssh [email protected] letsencrypt blog