At Firmhouse, we use Codeship to run all our tests, and we use Intercity Next to manage our servers. Intercity Next is built upon Dokku, which allows us to deploy our code by a simple
git push. Codeship supports a way to deploy your code once all the tests are green. Let's take a look how we can set this up using Codeship and Dokku.
Set up Codeship
In your Codeship account go to the project settings, and click on
In the list of deployment ways, click on
Add the following script in the text area and change the
YOUR_DOKKU_DEPLOY_ADDRESSto the actual Dokku address:
#!/bin/sh git fetch --unshallow || true git fetch origin "+refs/heads/*:refs/remotes/origin/*" git remote add dokku YOUR_DOKKU_DEPLOY_ADDRESS git push dokku master -f
Click on Create to set up this Build step.
Add the Codeship SSH key to your Dokku instance
Now that we've set up the Codeship deploy command to push to our Dokku on a green build, we also need to authorize Codeship to access the server.
Go to your Codeship project settings, and click on
When you scroll down, you find the
SSH public key.
Copy that SSH key
SSH into your Dokku server
Run the following command, don't forget to change
SSH_KEYto the key we just copied from Codeship:
$ echo "SSH_KEY" | sudo sshcommand acl-add dokku Codeship
We can now test to see if we set everything up correctly by making an empty commit to your project:
$ git commit --allow-empty -m "Testing deployment" && git push origin master
The empty commit will trigger a new build on Codeship, and if everything is configured correctly, it will also deploy the code to your Dokku server!