Docker - Continuous integration

> Virtualization - (Virtual Machine|Container) > Docker

1 - About

Docker integration with continuous integration system in order to build and publish

3 - Travis

3.1 - Build and deployment script to Docker Hub

deploy_dockerhub.sh
#!/bin/sh
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
if [ "$TRAVIS_BRANCH" = "master" ]; then
    TAG="latest"
else
    TAG="$TRAVIS_BRANCH"
fi
docker build -f Dockerfile -t $TRAVIS_REPO_SLUG:$TAG .
docker push $TRAVIS_REPO_SLUG

where:

Advertising

3.2 - Deployment to Heroku

deploy_heroku.sh
#!/bin/sh
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
heroku plugins:install heroku-container-registry
docker login -e _ -u _ --password=$HEROKU_API_KEY registry.heroku.com
heroku container:push web --app $HEROKU_APP_NAME

3.3 - .travis.yml configuration file

after_success:
  - sh .travis/deploy_dockerhub.sh
  - test “$TRAVIS_BRANCH” = “master” && sh .travis/deploy_heroku.sh

where:

  • the file deploy_dockerhub.sh and deploy_heroku.sh are located under a .travis directory in the code repository.

4 - Documentation / Reference