From acf3771ea83a5437b07106d92435452ec8747fce Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Wed, 1 Nov 2017 18:15:33 -0700 Subject: [PATCH 1/3] automation: Always try to cache using the latest master build This change makes us always try to use the latest master builds of the intermediate images for the --cache-from option in our docker build of the supervisor. This prevents cache misses when we're rebasing a branch and a PR has been merged that modifies a component that we're not modifying in the current branch. For example: Branch 1 modifies the base image. Branch 2 only modifies the nodejs code. Branch 1 gets merged before Branch 2, so in our Branch2 PR we rebase from master - in the next build for Branch 2, we'll have a cache miss on the base image, unless we're using the last master for caching. Change-Type: patch Signed-off-by: Pablo Carranza Velez --- automation/build.sh | 47 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/automation/build.sh b/automation/build.sh index 257e19a9..2c92b8c2 100755 --- a/automation/build.sh +++ b/automation/build.sh @@ -62,36 +62,29 @@ BASE_CACHE=$BASE_IMAGE GO_CACHE=$GO_IMAGE NODE_CACHE=$NODE_IMAGE +TARGET_CACHE_MASTER=resin/$ARCH-supervisor:master +BASE_CACHE_MASTER=resin/$ARCH-supervisor-base:master +GO_CACHE_MASTER=resin/$ARCH-supervisor-go:master +NODE_CACHE_MASTER=resin/$ARCH-supervisor-node:master + CACHE_FROM="" +function tryPullForCache() { + image=$1 + docker pull $image && { + CACHE_FROM="$CACHE_FROM --cache-from $image" + } || true +} + # Attempt to pull images for cache # Only if the pull succeeds we add a --cache-from option -docker pull $TARGET_CACHE || { - TARGET_CACHE=resin/$ARCH-supervisor:master - docker pull $TARGET_CACHE -} && { - CACHE_FROM="$CACHE_FROM --cache-from $TARGET_CACHE" -} || true - -docker pull $BASE_CACHE || { - BASE_CACHE=resin/$ARCH-supervisor-base:master - docker pull $BASE_CACHE -} && { - CACHE_FROM="$CACHE_FROM --cache-from $BASE_CACHE" -} || true - -docker pull $NODE_CACHE || { - NODE_CACHE=resin/$ARCH-supervisor-node:master - docker pull $NODE_CACHE -} && { - CACHE_FROM="$CACHE_FROM --cache-from $NODE_CACHE" -} || true - -docker pull $GO_CACHE || { - GO_CACHE=resin/$ARCH-supervisor-go:master - docker pull $GO_CACHE -} && { - CACHE_FROM="$CACHE_FROM --cache-from $GO_CACHE" -} || true +tryPullForCache $TARGET_CACHE +tryPullForCache $TARGET_CACHE_MASTER +tryPullForCache $BASE_CACHE +tryPullForCache $BASE_CACHE_MASTER +tryPullForCache $GO_CACHE +tryPullForCache $GO_CACHE_MASTER +tryPullForCache $NODE_CACHE +tryPullForCache $NODE_CACHE_MASTER if [ "$ENABLE_TESTS" = "true" ]; then make ARCH=$ARCH IMAGE=$GO_IMAGE test-gosuper From ab1be2c12d1097e29de4f4913c94ed4084ea531d Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Wed, 1 Nov 2017 19:04:10 -0700 Subject: [PATCH 2/3] Improve caching when building gosuper It seems that the ARG ARCH causes a cache miss in the next RUN statement (for some reason our use of cache-from in the other stages of the build works better, but here it always causes a miss). We move the ARG statement to later in the Dockerfile, just before actually using it. Hopefully this will improve caching for most supervisor builds. Change-Type: patch Signed-off-by: Pablo Carranza Velez --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4e1a6c15..ff65cf09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,6 @@ RUN cd /source && bash -ex build.sh # Build golang supervisor FROM debian:jessie-20170723 as gosuper -ARG ARCH RUN apt-get update \ && apt-get install -y \ @@ -95,6 +94,7 @@ WORKDIR /go/src/resin-supervisor/gosuper ENV GOOS linux ENV GO386=387 +ARG ARCH RUN bash ./build.sh RUN rsync -a --delete /go/bin/gosuper /build/ From 219dc2874bf03d103e7f5a658d239c9b73af5af6 Mon Sep 17 00:00:00 2001 From: "resin-io-versionbot[bot]" Date: Thu, 2 Nov 2017 21:44:14 +0000 Subject: [PATCH 3/3] v6.4.1 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fb85e79..a89656d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! This project adheres to [Semantic Versioning](http://semver.org/). +## v6.4.1 - 2017-11-02 + +* Improve caching when building gosuper #520 [Pablo Carranza Velez] +* Automation: Always try to cache using the latest master build #520 [Pablo Carranza Velez] + ## v6.4.0 - 2017-11-01 * Fixes #511, add support for new supervisor image for x86 with quark cpu boards. #512 [Trong Nghia Nguyen] diff --git a/package.json b/package.json index a2083d44..dcc1658e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "resin-supervisor", "description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.", - "version": "6.4.0", + "version": "6.4.1", "license": "Apache-2.0", "repository": { "type": "git",