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 <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-07-17 17:11:24 -03:00
parent 8dfc559126
commit fa8116d97c
3 changed files with 18 additions and 19 deletions

View File

@ -12,6 +12,7 @@
# * ENABLE_TESTS # * ENABLE_TESTS
# * PUBNUB_SUBSCRIBE_KEY, PUBNUB_PUBLISH_KEY, MIXPANEL_TOKEN: default keys to inject in the supervisor image # * 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 # * 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. # Builds the supervisor for the architecture defined by $ARCH.
# Will produce and push an image tagged as resin/$ARCH-supervisor:$TAG # 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. # 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 # 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 # to the docker registry.
# so that devices with older docker versions can pull it from there (it's a v1 registry).
# If CLEANUP is "true", all images will be removed after pushing - including any relevant images # 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! # that may have been on the host from before the build, so be careful!
# If ENABLE_TESTS is "true", tests will be run. # If ENABLE_TESTS is "true", tests will be run.
@ -108,15 +108,14 @@ export MIXPANEL_TOKEN
make IMAGE=$TARGET_IMAGE supervisor make IMAGE=$TARGET_IMAGE supervisor
if [ "$PUSH_IMAGES" = "true" ]; then if [ "$PUSH_IMAGES" = "true" ]; then
if [ -n "$DOCKER_PASSWORD" ]; then
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
fi
make IMAGE=$TARGET_IMAGE deploy 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 if [ -n "$EXTRA_TAG" ]; then
docker tag $TARGET_IMAGE resin/$ARCH-supervisor:$EXTRA_TAG docker tag $TARGET_IMAGE resin/$ARCH-supervisor:$EXTRA_TAG
make IMAGE=resin/$ARCH-supervisor:$EXTRA_TAG deploy 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 fi
# Try to push the intermediate images to improve caching in future builds # Try to push the intermediate images to improve caching in future builds

View File

@ -72,7 +72,7 @@ resinApi._request(_.extend({
return resinApi.post({ return resinApi.post({
resource: 'supervisor_release', resource: 'supervisor_release',
body: { body: {
image_name: `registry.resinstaging.io/resin/${arch}-supervisor`, image_name: `resin/${arch}-supervisor`,
supervisor_version: tag, supervisor_version: tag,
device_type: deviceType.slug, device_type: deviceType.slug,
is_public: true is_public: true

View File

@ -4,7 +4,8 @@ defaults: &defaults
- image: library/docker:stable - image: library/docker:stable
working_directory: /tmp/build working_directory: /tmp/build
steps: steps:
- setup_remote_docker - setup_remote_docker:
reusable: true
- run: - run:
name: Check docker is running and install git name: Check docker is running and install git
command: | command: |
@ -25,20 +26,25 @@ defaults: &defaults
name: Start the docker-in-docker builder and build $ARCH-supervisor name: Start the docker-in-docker builder and build $ARCH-supervisor
no_output_timeout: 10800 no_output_timeout: 10800
command: | command: |
# build the dind image
docker build --rm=false --tag builder -f automation/Dockerfile .
# start the dind container # start the dind container
echo "Starting the dind builder"
dind=$(docker run --privileged -d builder) dind=$(docker run --privileged -d builder)
# confirm it's running
docker ps
VERSION_TAG=v$(jq .version package.json | sed 's/"//g') VERSION_TAG=v$(jq .version package.json | sed 's/"//g')
if [ "${CIRCLE_BRANCH}" = "master" ]; then if [ "${CIRCLE_BRANCH}" = "master" ]; then
EXTRA_BUILD_ARGS="-e EXTRA_TAG=$VERSION_TAG" EXTRA_BUILD_ARGS="-e EXTRA_TAG=$VERSION_TAG"
else else
EXTRA_BUILD_ARGS="" EXTRA_BUILD_ARGS=""
fi fi
echo "Starting build.sh"
# start the build for this architecture # 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 if [ "${CIRCLE_BRANCH}" = "master" ] && [ "${DEPLOY_TO_RESIN}" = "true" ]; then
echo "Deploying to Resin API (staging)" 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 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 <<: *defaults
environment: environment:
DOCKER_USERNAME: travisciresin DOCKER_USERNAME: travisciresin
DOCKER_EMAIL: accounts+travisci+docker@resin.io
ARCH: amd64 ARCH: amd64
PUSH_IMAGES: "true" PUSH_IMAGES: "true"
STAGING_API_ENDPOINT: https://api.resinstaging.io STAGING_API_ENDPOINT: https://api.resinstaging.io
@ -61,7 +66,6 @@ jobs:
<<: *defaults <<: *defaults
environment: environment:
DOCKER_USERNAME: travisciresin DOCKER_USERNAME: travisciresin
DOCKER_EMAIL: accounts+travisci+docker@resin.io
ARCH: i386 ARCH: i386
PUSH_IMAGES: "true" PUSH_IMAGES: "true"
STAGING_API_ENDPOINT: https://api.resinstaging.io STAGING_API_ENDPOINT: https://api.resinstaging.io
@ -70,7 +74,6 @@ jobs:
<<: *defaults <<: *defaults
environment: environment:
DOCKER_USERNAME: travisciresin DOCKER_USERNAME: travisciresin
DOCKER_EMAIL: accounts+travisci+docker@resin.io
ARCH: armel ARCH: armel
PUSH_IMAGES: "true" PUSH_IMAGES: "true"
STAGING_API_ENDPOINT: https://api.resinstaging.io STAGING_API_ENDPOINT: https://api.resinstaging.io
@ -79,7 +82,6 @@ jobs:
<<: *defaults <<: *defaults
environment: environment:
DOCKER_USERNAME: travisciresin DOCKER_USERNAME: travisciresin
DOCKER_EMAIL: accounts+travisci+docker@resin.io
ARCH: armv7hf ARCH: armv7hf
PUSH_IMAGES: "true" PUSH_IMAGES: "true"
STAGING_API_ENDPOINT: https://api.resinstaging.io STAGING_API_ENDPOINT: https://api.resinstaging.io
@ -88,7 +90,6 @@ jobs:
<<: *defaults <<: *defaults
environment: environment:
DOCKER_USERNAME: travisciresin DOCKER_USERNAME: travisciresin
DOCKER_EMAIL: accounts+travisci+docker@resin.io
ARCH: aarch64 ARCH: aarch64
PUSH_IMAGES: "true" PUSH_IMAGES: "true"
STAGING_API_ENDPOINT: https://api.resinstaging.io STAGING_API_ENDPOINT: https://api.resinstaging.io
@ -97,7 +98,6 @@ jobs:
<<: *defaults <<: *defaults
environment: environment:
DOCKER_USERNAME: travisciresin DOCKER_USERNAME: travisciresin
DOCKER_EMAIL: accounts+travisci+docker@resin.io
ARCH: rpi ARCH: rpi
PUSH_IMAGES: "true" PUSH_IMAGES: "true"
STAGING_API_ENDPOINT: https://api.resinstaging.io STAGING_API_ENDPOINT: https://api.resinstaging.io