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

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. 

Pre-reqs:
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

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 1; the adjacent article text explains that also, if you have not already create an account with Travis CI.
version: '3'
services:
   web:
      build:
         context: .
         dockerfile: Dockerfile.dev
      ports:
         - "3000:3000"
      volumes:
         - /app/node_modules
         - .:/app
   tests:
      build:
         context: .
         dockerfile: Dockerfile.dev
      volumes:
                   - /app/node_modules
                   - .:/app
      command: ["npm", "run", "test"]

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 2, showing docker-compose up --build; the adjacent article text explains that $ docker-compose up -build.

$ docker-compose up –build

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 3; the adjacent article text explains that $ docker-compose up -build.
Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 4; the adjacent article text explains that $ 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

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 5, showing rootldocker0i; the adjacent article text explains that the walkthrough 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

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 6, showing abtechpbryant / dockerinferno; the adjacent article text explains that $ 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.

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 7, showing changelog Documentation; the step instructs the user to 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

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 8; the step instructs the user to enable your Repo.
language: generic
sudo: required
 
services:
  - docker
 
before_install:
  - docker build -t pbryant/docker-inferno -f Dockerfile.dev .
 
script:
  - docker run -e CI=true pbryant/docker-inferno npm run test
Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 9; the step instructs the user to enable your Repo.

$ git add .

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

$  git push origin master

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 10; the adjacent article text explains that 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.

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

Screenshot from the Docker Compose With GitHub and Travis CI walkthrough at step 11; the adjacent article text explains that 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.

Summary:
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.

Keep exploring

Choose your next step

Continue with the path that best matches the architecture or operating challenge in front of you.

Leave a Reply

Discover more from Digital Thought Disruption

Subscribe now to keep reading and get access to the full archive.

Continue reading