March 23, 2017
Quick Start/Essentials
# let's say your Dokku server is set to run with example.com as its hostname # create new app called "helloworld" - repeat for each app dokku apps:create helloworld # by default (if Dokku is running on virtual host mode) Dokku will setup helloworld.example.com # to add an additional domain: helloworld2.com # to the helloworld app, in addition to the # default domain name (helloworld.example.COM) dokku domains:add helloworld helloworld2.com # if your app runs on a non-standard port, map it to port 80 (HTTP) and 443 (HTTPS) # let's say your app runs on port 9999 dokku proxy:ports-add helloworld http:80:9999 dokku proxy:ports-add helloworld https:443:9999 # to remove a port-mapping dokku proxy:ports-remove httpbin http:8080:8080 # install letsencrypt plugin for dokku sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git # set letsencrypt email for helloworld app dokku config:set --no-restart helloworld [email protected] # request certificate # for ALL domains associated with the app # (both helloworld2.com and helloworld.example.com) dokku letsencrypt helloworld
Pushing code to Dokku server
# SETUP: you only need to do this once # dokku = git remote name - keep it as is # dokku = username to push code to dokku server - do not modify # example.com = your dokku server hostname # helloworld = app name, the one you created in the previous step git remote add dokku [email protected]:helloworld # PUSH: run the command every time you need to deploy new code # dokku: git remote name # master: git branch you want to push to the server git push dokku master
Apps
# create new app dokku apps:create <apps-name> # delete app dokku apps:destroy <apps-name> # list all apps dokku apps:list
Persistent Storage
# create the directory, set permissions # helloworld: arbitrary name. I recommend setting this to the Dokku app name mkdir -p /var/lib/dokku/data/storage/helloworld chown -R dokku:dokku /var/lib/dokku/data/storage/helloworld chown -R 32767:32767 /var/lib/dokku/data/storage/helloworld # mount storage folder for app helloworld # on host: /var/lib/dokku/data/storage/helloworld # on container: /var/www/html/data dokku storage:mount helloworld /var/lib/dokku/data/storage/helloworld:/var/www/html/data # restart app to apply changes # helloworld: Dokku app name dokku ps:restart helloworld # view storage mounts dokku storage:report
Update: 10/8/2017:
Maintenance
# If dokku acts weird (e.g. after a restart) # If dokku misroutes requests (e.g. wrong app being served on wrong virtualhost/domain) dokku ps:restartall # If you want dokku to rebuild ALL apps dokku ps:rebuildall # list proxy port-mapping dokku proxy:report # Update (Debian-based installs) # stop all apps first dokku --quiet apps:list | xargs -L1 dokku ps:stop # upgrade sudo apt-get install -qq -y dokku herokuish sshcommand plugn # You may need to rebuild apps dokku ps:rebuildall
Never miss new posts
Get the latest tech innovation news from Ryan delivered straight to your inbox!