From fa8116d97ca7b593a51fc9edd92d8278c5fe84eb Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Mon, 17 Jul 2017 17:11:24 -0300 Subject: [PATCH] Disable pushing to registry.resinstaging.io, and use build environment to login to dockerhub Also, avoid building the dind builder twice, and try to get a reusable docker instance. Change-Type: patch Signed-off-by: Pablo Carranza Velez --- automation/build.sh | 11 +++++------ automation/deploy-to-resin.js | 2 +- circle.yml | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/automation/build.sh b/automation/build.sh index c891f1f1..4bd5461f 100755 --- a/automation/build.sh +++ b/automation/build.sh @@ -12,6 +12,7 @@ # * ENABLE_TESTS # * PUBNUB_SUBSCRIBE_KEY, PUBNUB_PUBLISH_KEY, MIXPANEL_TOKEN: default keys to inject in the supervisor image # * EXTRA_TAG: when PUSH_IMAGES is true, additional tag to push to the registries +# * DOCKER_USERNAME, DOCKER_PASSWORD: if the password is set, then these will be used to login to dockerhub before pushing # # Builds the supervisor for the architecture defined by $ARCH. # Will produce and push an image tagged as resin/$ARCH-supervisor:$TAG @@ -24,8 +25,7 @@ # In all of these cases it will use "master" if $TAG is not found. # # If PUSH_IMAGES is "true", it will also push the supervisor and intermediate images -# to the docker registry. The supervisor image will also be pushed to registry.resinstaging.io -# so that devices with older docker versions can pull it from there (it's a v1 registry). +# to the docker registry. # If CLEANUP is "true", all images will be removed after pushing - including any relevant images # that may have been on the host from before the build, so be careful! # If ENABLE_TESTS is "true", tests will be run. @@ -108,15 +108,14 @@ export MIXPANEL_TOKEN make IMAGE=$TARGET_IMAGE supervisor if [ "$PUSH_IMAGES" = "true" ]; then + if [ -n "$DOCKER_PASSWORD" ]; then + docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD + fi make IMAGE=$TARGET_IMAGE deploy - docker tag $TARGET_IMAGE registry.resinstaging.io/$TARGET_IMAGE - make IMAGE=registry.resinstaging.io/$TARGET_IMAGE deploy if [ -n "$EXTRA_TAG" ]; then docker tag $TARGET_IMAGE resin/$ARCH-supervisor:$EXTRA_TAG make IMAGE=resin/$ARCH-supervisor:$EXTRA_TAG deploy - docker tag $TARGET_IMAGE registry.resinstaging.io/resin/$ARCH-supervisor:$EXTRA_TAG - make IMAGE=registry.resinstaging.io/resin/$ARCH-supervisor:$EXTRA_TAG deploy fi # Try to push the intermediate images to improve caching in future builds diff --git a/automation/deploy-to-resin.js b/automation/deploy-to-resin.js index 7bb44ce6..15f0df80 100644 --- a/automation/deploy-to-resin.js +++ b/automation/deploy-to-resin.js @@ -72,7 +72,7 @@ resinApi._request(_.extend({ return resinApi.post({ resource: 'supervisor_release', body: { - image_name: `registry.resinstaging.io/resin/${arch}-supervisor`, + image_name: `resin/${arch}-supervisor`, supervisor_version: tag, device_type: deviceType.slug, is_public: true diff --git a/circle.yml b/circle.yml index 7686c05a..2ad69cd2 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,8 @@ defaults: &defaults - image: library/docker:stable working_directory: /tmp/build steps: - - setup_remote_docker + - setup_remote_docker: + reusable: true - run: name: Check docker is running and install git command: | @@ -25,20 +26,25 @@ defaults: &defaults name: Start the docker-in-docker builder and build $ARCH-supervisor no_output_timeout: 10800 command: | - # build the dind image - docker build --rm=false --tag builder -f automation/Dockerfile . # start the dind container + echo "Starting the dind builder" dind=$(docker run --privileged -d builder) - # confirm it's running - docker ps VERSION_TAG=v$(jq .version package.json | sed 's/"//g') if [ "${CIRCLE_BRANCH}" = "master" ]; then EXTRA_BUILD_ARGS="-e EXTRA_TAG=$VERSION_TAG" else EXTRA_BUILD_ARGS="" fi + echo "Starting build.sh" # start the build for this architecture - docker exec -it -e TAG=${CIRCLE_BRANCH} -e ARCH=${ARCH} -e PUSH_IMAGES=${PUSH_IMAGES} $EXTRA_BUILD_ARGS ${dind} bash automation/build.sh + docker exec -it \ + -e TAG=${CIRCLE_BRANCH} \ + -e ARCH=${ARCH} \ + -e PUSH_IMAGES=${PUSH_IMAGES} \ + -e DOCKER_USERNAME=${DOCKER_USERNAME} \ + -e DOCKER_PASSWORD=${DOCKER_PASSWORD} \ + $EXTRA_BUILD_ARGS \ + ${dind} bash automation/build.sh if [ "${CIRCLE_BRANCH}" = "master" ] && [ "${DEPLOY_TO_RESIN}" = "true" ]; then echo "Deploying to Resin API (staging)" docker exec -it -e ARCH=${ARCH} -e TAG=$VERSION_TAG -e API_KEY=$STAGING_API_KEY -e API_ENDPOINT=$STAGING_API_ENDPOINT ${dind} node automation/deploy-to-resin.js @@ -52,7 +58,6 @@ jobs: <<: *defaults environment: DOCKER_USERNAME: travisciresin - DOCKER_EMAIL: accounts+travisci+docker@resin.io ARCH: amd64 PUSH_IMAGES: "true" STAGING_API_ENDPOINT: https://api.resinstaging.io @@ -61,7 +66,6 @@ jobs: <<: *defaults environment: DOCKER_USERNAME: travisciresin - DOCKER_EMAIL: accounts+travisci+docker@resin.io ARCH: i386 PUSH_IMAGES: "true" STAGING_API_ENDPOINT: https://api.resinstaging.io @@ -70,7 +74,6 @@ jobs: <<: *defaults environment: DOCKER_USERNAME: travisciresin - DOCKER_EMAIL: accounts+travisci+docker@resin.io ARCH: armel PUSH_IMAGES: "true" STAGING_API_ENDPOINT: https://api.resinstaging.io @@ -79,7 +82,6 @@ jobs: <<: *defaults environment: DOCKER_USERNAME: travisciresin - DOCKER_EMAIL: accounts+travisci+docker@resin.io ARCH: armv7hf PUSH_IMAGES: "true" STAGING_API_ENDPOINT: https://api.resinstaging.io @@ -88,7 +90,6 @@ jobs: <<: *defaults environment: DOCKER_USERNAME: travisciresin - DOCKER_EMAIL: accounts+travisci+docker@resin.io ARCH: aarch64 PUSH_IMAGES: "true" STAGING_API_ENDPOINT: https://api.resinstaging.io @@ -97,7 +98,6 @@ jobs: <<: *defaults environment: DOCKER_USERNAME: travisciresin - DOCKER_EMAIL: accounts+travisci+docker@resin.io ARCH: rpi PUSH_IMAGES: "true" STAGING_API_ENDPOINT: https://api.resinstaging.io