Skip to content

Instantly share code, notes, and snippets.

@bradjones1
Created March 10, 2016 06:52
Show Gist options
  • Save bradjones1/eb236dcef07bb73a17d2 to your computer and use it in GitHub Desktop.
Save bradjones1/eb236dcef07bb73a17d2 to your computer and use it in GitHub Desktop.
GitLab CI yml for containerized Docker testing
stages:
- test
- spawn
- phpunit
- deploy
- cleanup
build_image:
cache:
untracked: true
script:
- whoami && docker info && docker-compose -v
- if [[ -n "$GITHUB_API_KEY" ]]; then composer config -g github-oauth.github.com "$GITHUB_API_KEY"; fi
- composer install --ignore-platform-reqs
- docker-compose -f docker-compose.ci.yml build
spawn_containers:
stage: spawn
script:
- docker-compose -f docker-compose.ci.yml up -d
unit_test:
stage: phpunit
script:
- docker exec -t $(docker-compose -f docker-compose.ci.yml ps -q web)
su -c '~www-data/html/tests/scripts/unit-testing.sh' -s /bin/bash www-data
deploy:
stage: deploy
only:
- master
script:
- docker build -t "$DEPLOY_SERVER"/"$DEPLOY_REPO" .
- docker login --username="${DEPLOY_USER}" --password="${DEPLOY_PASS}" [email protected] "$DEPLOY_SERVER"
- docker push "$DEPLOY_SERVER"/"$DEPLOY_REPO"
- docker rmi "$DEPLOY_SERVER"/"$DEPLOY_REPO"
cleanup:
stage: cleanup
when: always
script:
- docker-compose -f docker-compose.ci.yml down
- composer config -g --unset github-oauth.github.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment