From 7743faff11b670f666f1f1af4c7432179a0910dc Mon Sep 17 00:00:00 2001 From: Gunnar Schaefer Date: Wed, 22 Nov 2017 12:37:19 -0800 Subject: [PATCH] Send CI image to Docker Hub --- .travis.yml | 26 ++++++++++++++++---------- docker/build-trigger.sh | 31 ------------------------------- 2 files changed, 16 insertions(+), 41 deletions(-) delete mode 100755 docker/build-trigger.sh diff --git a/.travis.yml b/.travis.yml index d8d8adab1..5aec1a09d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,29 +6,35 @@ services: env: global: - - secure: HELJx6WPr+W2S0FV47KkRdlS9NCqlMcdRMK8xWgRqqrEPv24KEvNnHxCy0tRbzITqadYtyvI1MtqtmpG04uty8Gpkc7w6L6LMJ/OuLG0gVX7AnaUovYTlY04m1/L9oyzOrTDXk5J/BKbcyiz7uJtkTc/A8MMZAFfZh7hmhLID78= # BUILD_TRIGGER_URL + - DOCKER_DIR="$HOME/.cache/docker" + - secure: "HhT1TdJcpqys8juVMw/DIZeK7oD4595TEKH5KlowH7MvwwFAUyQFb5W63F8dgk7elvRG+3fmga/m1JfXO+Iu7PVD912eiNDagW9aB3CEl3Z8zg+JUL8IjpMCkyKQDyJMnfOkrzdxdaqfOK+WmF+13f2qBu9Kc7wdXuzgHQrg4+0=" # CI_REGISTRY_USER + - secure: "hh7VDZnkxgl/vqHtS4IpXfIAckKpVQvoCzNW7fstr5Mcu8KNiCWIPgObBRm+m13aqpcFTMWQ6lT2kzORz2wWRbDeVhI1eGWOJswGNHPHZLO0Jaei6yfY2nY2mpxZbl+vdg00jkN64mi1ab3e++QgeLFruW0gyNefXX7E5L/mHTs=" # CI_REGISTRY_PASS -#cache: -# directories: -# - $TESTDATA_DIR -# - $DOCKER_DIR +cache: + directories: + - $DOCKER_DIR before_install: - sudo apt-get update - sudo apt-get -y install docker-ce realpath + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASS install: true script: + - test -f "$DOCKER_DIR/image.tar" && docker load -i "$DOCKER_DIR/image.tar" || true + - docker build -t core:build --target build . + - docker build -t core:dist --target dist . + - docker build -t core:testing --target testing . + - docker save -o "$DOCKER_DIR/image.tar" $(docker history -q reaper:build | grep -v '') $(docker history -q reaper:dist | grep -v '') - ./tests/bin/run-tests-docker.sh after_success: - - if [ "$TRAVIS_BRANCH" == "master" -o "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then - bash <(curl -s https://codecov.io/bash) -cF python; - fi - if [ "$TRAVIS_TAG" ]; then - ./docker/build-trigger.sh Tag "$TRAVIS_TAG" "$BUILD_TRIGGER_URL"; + docker tag core:dist scitran/core:$TRAVIS_TAG; + docker push scitran/core:$TRAVIS_TAG; fi - if [ "$TRAVIS_EVENT_TYPE" == "push" -a "$TRAVIS_BRANCH" == "master" ]; then - ./docker/build-trigger.sh Branch "$TRAVIS_BRANCH" "$BUILD_TRIGGER_URL"; + docker tag core:dist scitran/core:latest; + docker push scitran/core:latest; fi diff --git a/docker/build-trigger.sh b/docker/build-trigger.sh deleted file mode 100755 index 8c012e8e8..000000000 --- a/docker/build-trigger.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -# Triggers an auto-build on Docker Hub for the given source control reference. -# -# Example usage: ./build-trigger Tag 1.0.0 https://registry.hub.docker.com/u/scitran/reaper/trigger/11111111-2222-3333-4444-abcdefabcdef/ - -set -e - -if [ $# -ne 3 ] ; then - >&2 echo "Usage: $( basename $0 ) " - exit 1 -fi - -SOURCE_CONTROL_REF_TYPE="${1}" -SOURCE_CONTROL_REF_NAME="${2}" -TRIGGER_URL="${3}" - -if [ -z "${SOURCE_CONTROL_REF_TYPE}" ] ; then - >&2 echo "Source control reference type not provided. Skipping build trigger." - exit 1 -fi - -if [ -z "${SOURCE_CONTROL_REF_NAME}" ] ; then - >&2 echo "Source control tag name not provided. Skipping build trigger." - exit 1 -fi - -TRIGGER_PAYLOAD="{\"source_type\": \"${SOURCE_CONTROL_REF_TYPE}\", \"source_name\": \"${SOURCE_CONTROL_REF_NAME}\"}" -curl -H "Content-Type: application/json" --data "${TRIGGER_PAYLOAD}" -X POST "${TRIGGER_URL}" ->&2 echo ->&2 echo "Docker Hub build for ${SOURCE_CONTROL_REF_TYPE} '${SOURCE_CONTROL_REF_NAME}' triggered."