Why Change?

Heroku is removing their free tier.

Vultr is inexpensive and fast.

Dokku makes it easy to self host.

TLDR; (Too Long Didn't Read)

Migration worked, costs are down, speed is up.

Setting Up Vultr

I use VULTR because they are cheaper than most other cloud providers and their VMs are more performant per core and with optional NVMe storage its blazing fast.

Choose Cloud Compute as Server Type.

AMD High Performance as CPU type.

Choose the location closest to you are your customers. Vultr has 25 locations around the globe.

Operating System: Ubuntu 22.04 LTS x64 or newer.

Server Size: 25 GB NVMe, 1 vCPU, 1 GB Memory, 1 TB Bandwidth

Auto Backups, only $1.20/month extra.

Create your server hostname and label. You'll have to wait until the system is created to update your DNS with the IP.

Logging in and Updating

ssh-copy-id root@yourdomain.com
ssh root@yourdomain.com
apt update
apt upgrade -y
shutdown -r now

Installing Dokku on the VM

wget https://raw.githubusercontent.com/dokku/dokku/v0.28.1/bootstrap.sh
DOKKU_TAG=v0.28.1 bash bootstrap.sh

dokku domains:set-global yourdomain.com


echo "your-public-key-goes-here" | dokku ssh-keys:add admin

dokku apps:create your-app-name

dokku plugin:install https://github.com/dokku/dokku-postgres.git
dokku postgres:create your-db-name-production

dokku postgres:link your-db-name-production your-app-name

# Open Firewall to Web Traffic
ufw allow from any to any port 80
ufw allow from any to any port 443

HTTPS with LetsEncrypt.org

Free https is easy with the Let's Encrypt plugin for Dokku.

dokku config:set app-name DJANGO_ALLOWED_HOSTS=hostname.com
dokku domains:add app-name your-domain.com
dokku domains:set app-name mydomain.com  www.mydomain.com
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
dokku config:set --no-restart app-name DOKKU_LETSENCRYPT_EMAIL=your@email.com
dokku letsencrypt:enable app-name

Deploy Code Via Git Push

pip install cookiecutter
cookiecutter https://github.com/Jean-Zombie/cookiecutter-django-wagtail/

git init .
git add .
git commit -m "Initial Commit"
git remote add dokku dokku@hostname.com:projectname
git push dokku main

# Depending on how you manage your static files you may want to generate and commit them
python manage.py collectstatic

If you don't already have a python app, you can start with the heroku python-getting-started.

# To add Existing Repo to git
git init .
git add .
git commit -m "Initial Commit"
git remote 
git push dokku main:master

Resources

Dokku Plugins