References:
- Create a new Droplet on DigitalOcean
- Name the Droplet after your Domain (yourdomain.com)
- Choose Applications -> Dokku
- Create Droplet
- Access Dokku setup using the Server IP in the Browser
- ssh key is already filled in
- Configure the hostname (yourdomain.com)
- Check "Use virtualhost naming for apps"
- Finish Setup
- Install PostgreSQL on Dokku Server
- SSH to the server
cd /var/lib/dokku/plugins
git clone https://github.com/Kloadut/dokku-pg-plugin.git postgresql
dokku plugins-install
- Install Dokku client on dev machine
git clone [email protected]:progrium/dokku.git ~/.dokku
- Add to .zshrv
alias dokku='$HOME/.dokku/contrib/dokku_client.sh'
- Add the following to ~/.ssh/config:
Host <yourdomain.com>
RequestTTY yes
If you use a small instance type, add some swap to your server see docs
- (Optional) Add swap
- System has swap?
sudo swapon -s
orfree -m
- Check disk space
df -h
sudo fallocate -l 4G /swapfile
- Check if correct
ls -lh /swapfile
- Secure swap file
sudo chmod 600 /swapfile
- Verify swap file
ls -lh /swapfile
- Set up swap
sudo mkswap /swapfile
- Enable swap
sudo swapon /swapfile
- System has swap?
sudo swapon -s
orfree -m
- (Optional) Make swap permanent
sudo vim /etc/fstab
- At bottom, add
/swapfile none swap sw 0 0
- (Optional) Tweak swap settings
- Check swapiness
cat /proc/sys/vm/swappiness
- For a Desktop, a swappiness setting of 60 is not a bad value. For a VPS system, we'd probably want to move it closer to 0
- Set swapiness temp:
sudo sysctl vm.swappiness=10
- Set swapiness perm:
sudo vim /etc/sysctl.conf
and addvm.swappiness=10
- Check
vfs_cache_pressure
:cat /proc/sys/vm/vfs_cache_pressure
==100
- Set cache temp:
sudo sysctl vm.vfs_cache_pressure=50
- Set cache perm:
sudo vim /etc/sysctl.conf
and addvm.vfs_cache_pressure = 50
- Create a new rails app and
cd
into the directory - Initialize git and do first commit
git init && git add . && git commit -am 'First commit'
- Add remote
git remote add dokku [email protected]:<app_name>
dokku postgresql:create <app_name>
(must be the app name)dokku postgresql:link <app_name> <app_name>
- Push it
git push dokku master
dokku run rake db:migrate
dokku url
Create a .env
file and add at least export BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby