From 967e6a1b8ff12d78f998fda36163e0c751312f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20R?= Date: Thu, 14 Jul 2016 00:04:48 +0200 Subject: [PATCH] [Docker] Setup deployment of demo docker image (#28) --- .travis.yml | 9 +++++-- bin/.ci/docker_hub_push.sh | 49 ++++++++++++++++++++++++++++++++++++++ composer.lock | 10 ++++---- 3 files changed, 61 insertions(+), 7 deletions(-) create mode 100755 bin/.ci/docker_hub_push.sh diff --git a/.travis.yml b/.travis.yml index 66db7a36..0aefa3f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,10 @@ services: env: global: - COMPOSE_FILE="doc/docker-compose/base-dev.yml:doc/docker-compose/selenium.yml" + - INSTALL_EZ_INSTALL_TYPE=demo # list of behat arguments to test matrix: - - ARGS="--profile=rest --suite=fullJson" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/selenium.yml" + - ARGS="--profile=rest --suite=fullJson" COMPOSE_FILE="doc/docker-compose/base-prod.yml:doc/docker-compose/selenium.yml" REMOTE_IMAGE="ezsystems/ezplatform-demo" APP_PROD_IMAGE="ezplatform-demo" - ARGS="--profile=rest --suite=fullXml" SYMFONY_ENV=behat SYMFONY_DEBUG=1 - ARGS="--profile=core" SYMFONY_ENV=behat SYMFONY_DEBUG=1 @@ -18,7 +19,8 @@ env: branches: only: - master - - "1.3" + - /^\d.\d$/ + - /^v\d.\d.\d$/ # Update Docker and Docker Compose before_install: ./bin/.travis/trusty/update_docker.sh @@ -37,6 +39,9 @@ before_script: # using behat.yml which is a copy of behat.yml.dist with hostnames update by docker-compose.behat.yml script: docker-compose exec --user www-data app sh -c "php /scripts/wait_for_db.php; php bin/behat -vv $ARGS --tags=~@broken" +# Push prod image to docker hub on sucess (on tags) +after_success: if [ "$REMOTE_IMAGE" != "" ] && [ "$TRAVIS_TAG" != "" ]; then bin/.ci/docker_hub_push.sh ${APP_PROD_IMAGE} ${REMOTE_IMAGE}; fi + # disable mail notifications notifications: email: false diff --git a/bin/.ci/docker_hub_push.sh b/bin/.ci/docker_hub_push.sh new file mode 100755 index 00000000..dd3c0a1d --- /dev/null +++ b/bin/.ci/docker_hub_push.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env sh + +set -e + +# See .travis.yml for example use + +validateEnvironment() +{ + if [ "$DOCKER_EMAIL" = "" ]; then + echo "Environment variable DOCKER_EMAIL is not set. Bailing out !" + exit 1 + fi + if [ "$DOCKER_USERNAME" = "" ]; then + echo "Environment variable DOCKER_USERNAME is not set. Bailing out !" + exit 1 + fi + if [ "$DOCKER_PASSWORD" = "" ]; then + echo "Environment variable DOCKER_PASSWORD is not set. Bailing out !" + exit 1 + fi +} + +validateEnvironment + +if [ "$1" = "" ]; then + echo "Argument 1 variable APP_PROD_IMAGE is not set, format: ezplatform-demo. Bailing out !" + exit 1 +fi + + +if [ "$2" = "" ]; then + echo "Argument 2 variable REMOTE_IMAGE is not set, format: ezsystems/ezplatform-demo. Bailing out !" + exit 1 +fi + +APP_PROD_IMAGE="$1" +REMOTE_IMAGE="$2" + +# Debug +docker images + +# Login +docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" + +## TAG +docker tag "${APP_PROD_IMAGE}" "${REMOTE_IMAGE}:latest" + +echo "Pushing docker image with all tags : ${REMOTE_IMAGE}" +docker push "${REMOTE_IMAGE}" diff --git a/composer.lock b/composer.lock index 52136397..2fea3773 100644 --- a/composer.lock +++ b/composer.lock @@ -1057,16 +1057,16 @@ }, { "name": "ezsystems/ezpublish-kernel", - "version": "v6.4.1-rc1", + "version": "v6.4.1-rc2", "source": { "type": "git", "url": "https://github.com/ezsystems/ezpublish-kernel.git", - "reference": "b6c4c2e3e9935162c0b48615dfcf24f962debaff" + "reference": "96f15b1cb893da9dc2b84fac13389d2c8195732f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ezsystems/ezpublish-kernel/zipball/b6c4c2e3e9935162c0b48615dfcf24f962debaff", - "reference": "b6c4c2e3e9935162c0b48615dfcf24f962debaff", + "url": "https://api.github.com/repos/ezsystems/ezpublish-kernel/zipball/96f15b1cb893da9dc2b84fac13389d2c8195732f", + "reference": "96f15b1cb893da9dc2b84fac13389d2c8195732f", "shasum": "" }, "require": { @@ -1135,7 +1135,7 @@ ], "description": "Kernel used by ezsystems/ezplatform and derivatives. Provides the Content Repository, its APIs, and the application's Symfony framework integration.", "homepage": "http://share.ez.no", - "time": "2016-07-09 17:00:42" + "time": "2016-07-13 18:20:35" }, { "name": "ezsystems/platform-ui-assets-bundle",