mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-20 09:46:19 +00:00
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 <pablo@resin.io>
This commit is contained in:
parent
a1a020b074
commit
acf3771ea8
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user