Last active
May 8, 2018 04:19
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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