Here’s a (very) quick and dirty overview of the steps. Follow everything below in order and you should have your node.js app (optionally running SailsJS) deployed on a dokku server on DigitalOcean within a few minutes.
* Dokku – https://github.com/progrium/dokku
* MariaDB plugin – https://github.com/Kloadut/dokku-md-plugin
Set your SSH key into DigitalOcean if you haven’t already
cat ~/.ssh/id_rsa.pub | pbcopy
* Paste this key into digitalocean control panel.
* Select 1GB
* San Fran
* Select your existing SSH key.
* Virtio + backups (maybe virt network if need to connect)
Set up Dokku
* Visit in your browser:
* Submit, optionally setting the app URL to use subdomains. Most settings should default to correct at this point.
Initialize the app access dokku
cat ~/.ssh/id_rsa.pub | ssh [email protected] "sudo sshcommand acl-add dokku YOUR-APP-NAME"
** Note that if instead of YOUR-APP-NAME you put a full domain it will use that as the URL instead of setting up a subdomain. Eg api.dustinbolton.com instead of dustinbolton-api
Configuring local app
Initialize the local repo if you have not already
git init && git add -A && git commit -m "Initial commit"
Assign production (or staging) destination:
git remote add production [email protected]:YOUR-APP-NAME
Create file to tell server what to run on deployment:
touch Procfile && open Procfile
* Add the following into this new file & save:
web: sails lift
** For non-sails framework, instead of “sails lift” this would be “node app.js”.
Deploy & launch the app
git push -u production master
If you need to manually re-run the app or see the output of the run attempt (such as to troubleshoot):
ssh [email protected]
dokku run YOUR-APP-NAME sails lift
(or instead of “sails lift”, “node app.js”)
Adapted from the guide at:
MariaDB (mysql drop-in alternative) plugin:
git clone https://github.com/Kloadut/dokku-md-plugin mariadb
#git clone https://github.com/musicglue/dokku-user-env-compile.git user-env-compile
Create Database Instance
dokku mariadb:create YOUR-APP-NAME
* This creates the mariadb instance and links it to your app automatically since the name matches. The database name is “db” by default.
You can use the credentials displayed or access them via environmental variables such by:
Setting Custom Environment Variables
Database environment variables should automatically exist but I have seen them drop off. I have not found the cause yet and have decided to manually set the one(s) I need for the time being.
dokku config:set YOUR-APP-NAME DATABASE_URL=whateverhere
If you ever need to restart your app. Only change “YOUR-APP-NAME”:
docker restart `cat /home/dokku/YOUR-APP-NAME/CONTAINER`