Test/Dev Workflow Docker Compose pushed to GitHub & Travis CI

Posted by

In the previous article we covered how to deploy an app using Docker Compose.  In this article we will expand upon that and push our files to a GitHub Repo and connect the Repo to Travis CI for continual testing. 

Create a repository in Github – my example is docker-inferno

Also, if you have not already create an account with Travis CI

Let’s add a test component to our docker-compose yaml file

version: '3'
         context: .
         dockerfile: Dockerfile.dev
         - "3000:3000"
         - /app/node_modules
         - .:/app
         context: .
         dockerfile: Dockerfile.dev
                   - /app/node_modules
                   - .:/app
      command: ["npm", "run", "test"]

$ docker-compose up –build

As you can see our tests that came with the app worked and  we can once again hit the URL on port 3000

Now are Dev version of our app is complete

Now we need to push it to GitHub

$ git init

$ git add .

$ git commit -m “initial commit”

$ git remote add origin <URL from your Git Repo>

$ git push origin master

As you can see the files have been pushed to the repo

Now go to https://travis-ci.org/

Create an account if you don’t already have one and link it with your GitHub if you haven’t already done so.

Enable your Repo

Next step is to create a .travis.yml file

language: generic
sudo: required
  - docker
  - docker build -t pbryant/docker-inferno -f Dockerfile.dev .
  - docker run -e CI=true pbryant/docker-inferno npm run test

$ git add .

$ git commit -m “added .travis.yml file”

$  git push origin master

If you go back to your Travis page you will already see that Travis has grab the update and is acting off the yaml file you created and beginning to run tests

Completed and with no issues

Here is where we could update the Travis yaml file and have it deploy our application into any environment like Azure.  I will save that for a later date when we attempt to run a production style run leveraging docker.

There were a lot of moving parts in this multi-part blog.  If you stayed with me I showed you show to use Docker compose and do a full test/dev deployment on prem and have your application ready to be deployed into an environment using Travis.  As always, I hope ya’ll found this useful.

Leave a Reply