Continuous Deployment with Codeship and Dokku

Published Jul 03, 2017Last updated Dec 14, 2017
Continuous Deployment with Codeship and Dokku

The following steps will help you successfully deploy from Codeship to Dokku, so everytime you push to GitHub, Codeship will automatically run the deployment script as long as your tests pass.

This will not take long to implement. You only need the public ssh key from your Codeship project and the bash script below.

  • Save the public key of the Codeship project. It is found in Project Settings => General Settings.

  • In project repo create a folder labeled tmp at the top level, then save the ssh key as

  • Make sure you add tmp/*.pub to your .gitignore before pushing to GitHub. You may want to use a seperate branch for this, or even a submodule.

  • Make sure when pasting, all the contents are in a single line and not multiple lines.

  • Add the public key to your dokku server using the following command in console.

cat tmp/ | ssh root(at) "sudo sshcommand acl-add dokku codeship_projectname" 
  • In Codeship, go to Project Settings => Deployment. Configure your deployment pipeline.



  • Add the following lines to the custom script.
git fetch --unshallow || true git fetch origin "+refs/heads/*:refs/remotes/origin/*"
# checkout a remote branch with:
# git checkout -b test origin/test 
git remote add dokku dokku@[your-dokku-instance].com:projectname
git push dokku master

Now every time you build on Codeship, it should deploy to your Dokku server.

Discover and read more posts from Seth Bergman
get started