Skip to content

Instantly share code, notes, and snippets.

@irvingpop
Last active May 8, 2018 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irvingpop/1460678d33151620bb6d045e16d68672 to your computer and use it in GitHub Desktop.
Save irvingpop/1460678d33151620bb6d045e16d68672 to your computer and use it in GitHub Desktop.
Example Travis config to build, smoketest and publish a hab package as a docker container
sudo: required
dist: trusty
services: docker
language: bash
install:
- 'curl https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh | sudo bash'
branches:
only:
- master
env:
global:
- HAB_ORIGIN=myorigin
- DOCKER_ORIGIN=myorigin
- DOCKER_PASSWORD=ShouldBeATravisSecret
- HAB_AUTH_TOKEN=ReallyShouldBeATravisSecret
matrix:
- PLAN=nginx
- PLAN=mysql
- PLAN=redis
before_script:
- hab origin key download $HAB_ORIGIN
- hab origin key download -s $HAB_ORIGIN
- hab studio build ${PLAN}
- source results/last_build.env
- sudo hab pkg export docker --version
- hab pkg export docker -i "${DOCKER_ORIGIN}/${PLAN}" results/${pkg_artifact}
# smoke test the container
script:
- RUNNING_CONTAINER=$(docker run -td ${DOCKER_ORIGIN}/${PLAN})
- sleep 10
- docker logs $RUNNING_CONTAINER
- docker ps --no-trunc --filter id=${RUNNING_CONTAINER} --filter status=running | grep $PLAN
- docker exec -it $RUNNING_CONTAINER hab sup status | grep " up "
- docker exec -it $RUNNING_CONTAINER /hab/svc/${PLAN}/hooks/health_check
before_deploy:
- docker login -u "${DOCKER_ORIGIN}" -p "${DOCKER_PASSWORD}"
- docker tag "${DOCKER_ORIGIN}/${PLAN}:latest" "${DOCKER_ORIGIN}/${PLAN}:stable"
deploy:
- provider: script
skip_cleanup: true
script: hab pkg upload -c stable results/${pkg_artifact}
on:
branch: master
- provider: script
skip_cleanup: true
script: docker push "${DOCKER_ORIGIN}/${PLAN}"
on:
branch: master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment