WARNING

We no longer use dokku here, it was so buggy and crippled with updates that we abandoned it in the great November 2015 crash when we lost it's server...

Configure SSH

To make life easy, lets add the dokku/apps server to our ssh config

vim ~/.ssh/config

Add the following to the end of the file

Host dokku HostName apps1.psd401.net
User dokku

now ssh into the apps server to test the connection and initiate the handshake.

dokku@apps1.psd401.net

The password is the standard server password.

Go ahead and generate a ssh key if you don't have one

ssh-keygen -t rsa

Now copy it to the dokku server so you never have to enter the password

ssh-copy-id dokku@apps1.psd401.net

Configure your app

After you find your app and get it running succesfully on your local machine, open your git config.

vim .git/config

Add the following at the end of the file

[remote "production"] url = dokku@apps1.psd401.net:[app-name] fetch = +refs/heads/*:refs/remotes/production/*

Replace [app-name] with the short name of your application.

We need to tell dokku what to do with your app, add a new file at the root of your app named Procfile.

vim Procfile

Inside, add the following: web: [command to start]

Replace [command to start] with whatever it takes to start your app. For instance, web: node server.js would start server.js using node. Now add the Procfile to your repository and push to the server.

git add Procfile git commit -m "Added Doku Procfile"
git push production master

Your app should now be running on the apps server! If you find errors, see troubleshooting below.

Setup DNS

You will need to setup DNS to reflect your changes.

  • Open the DNS manager in Windows
  • Find the apps1 subdomain
  • Create a new Alias (CNAME)
  • Set the name to your app name
  • Set the Fully Qualified Domain Name for target host to apps1.psd401.net

Wait for DNS to propogate, and test within 10 minutes. Your app should be up and running at http://[app-name].apps1.psd401.net!

Changing the DNS name

If you would like your app reachable at http://[app-name].psd401.net (Or anything really) follow the next steps.

  • Go back to the psd401 DNS group
  • Create a new Alias like before
  • Set the name to the domain name you would like your app reached at, ([app-name])
  • Set the target to [app-name].apps1.psd401.net (For reduncency)

Now if you were to try and go to the new domain name, you would see nginx errors. To fix that, we need to ssh into the dokku server and configure our app's container.

ssh dokku@apps1.psd401.net

Now that you are in the dokku server, run the following command with all the domain names you would like your app to be reached at.

dokku domains:set [app-name].apps1.psd401.net [app-name].psd401.net whatever-else.psd401.net

Make sure you keep the apps1 domain name, or else your Alias won't work.

Your app should now be live!

Pro Tip: You might want to open it up to the outside world DNS.

Troubleshooting

If the app fails to upload and run on the server, here are a few things to check and will be nessisary to do to re-push the app.

First, get into the server
ssh dokku@apps1.psd401.net

List all apps currently running
docker ps

If you do not see your app, it probably failed to start. To see it, add -a
docker ps -a

You should see an output similar to this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3e9d9dac6095 app/greenscreen:latest /bin/bash -c /start 42 minutes ago Exit 0 prickly_mccarthy
17b2cdd5ba34 app/geekzone:latest /bin/bash -c /start 42 minutes ago Up 42 minutes 0.0.0.0:49155->5000/tcp backstabbing_bardeen
4ab8879a3642 app/cms:latest /bin/bash -c /start 42 minutes ago Up 42 minutes 0.0.0.0:49154->5000/tcp evil_einstein
043f1a96757e app/cm:latest /bin/bash -c /start 42 minutes ago Up 42 minutes 0.0.0.0:49153->5000/tcp clever_hawking
31d88dd33914 app/greenscreen:latest /bin/bash -c /start 26 hours ago Exit -1 suspicious_albattani
......

Find your app's container ID and delete it and any other related apps with docker. Replace the containers IDs below with yours.
docker rm -f 31d88dd33914 043f1a96757e

If you try and repush the app, it will probably still fail saying the port is unavailable.
To resolve this, delete your app's PORT file.
rm -rf /home/dokku/[app-name]/PORT

Now repush!
If you have fixed your code/Procfile, you should be good to go!