About
Docker integration with continuous integration system in order to build and publish
Articles Related
Travis
Build and deployment script to Docker Hub
#!/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:
- docker command:
- Travis System from Default-Environment-Variables
- TRAVIS_REPO_SLUG is the slug (in form: owner_name/repo_name) of the repository currently being built. See Default-Environment-Variables
- TRAVIS_BRANCH is the name of the branch.
- DOCKER_EMAIL, DOCKER_USER, DOCKER_PASS are Travis environment variable of the Travis repo.
Deployment to Heroku
#!/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
.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.