mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-25 00:11:06 +00:00
Fix cache usage for builds
Change-type: patch
This commit is contained in:
parent
095ec0620f
commit
0ad5d8688c
@ -58,21 +58,21 @@ NODE_CACHE_MASTER=balena/$ARCH-supervisor-node:master$DEBUG
|
|||||||
NODE_BUILD_CACHE_MASTER=balena/$ARCH-supervisor-node:master-build$DEBUG
|
NODE_BUILD_CACHE_MASTER=balena/$ARCH-supervisor-node:master-build$DEBUG
|
||||||
|
|
||||||
CACHE_FROM=""
|
CACHE_FROM=""
|
||||||
function tryPullForCache() {
|
function useCache() {
|
||||||
image=$1
|
image=$1
|
||||||
docker pull $image && {
|
# Always add the cache because we can't do it from
|
||||||
|
# a subshell and specifying a missing image is fine
|
||||||
CACHE_FROM="$CACHE_FROM --cache-from $image"
|
CACHE_FROM="$CACHE_FROM --cache-from $image"
|
||||||
} || true
|
# Pull in parallel for speed
|
||||||
|
docker pull $image &
|
||||||
}
|
}
|
||||||
|
|
||||||
# Attempt to pull images for cache
|
useCache $TARGET_CACHE
|
||||||
# Only if the pull succeeds we add a --cache-from option
|
useCache $TARGET_CACHE_MASTER
|
||||||
tryPullForCache $TARGET_CACHE &
|
useCache $NODE_CACHE
|
||||||
tryPullForCache $TARGET_CACHE_MASTER &
|
useCache $NODE_CACHE_MASTER
|
||||||
tryPullForCache $NODE_CACHE &
|
useCache $NODE_BUILD_CACHE
|
||||||
tryPullForCache $NODE_CACHE_MASTER &
|
useCache $NODE_BUILD_CACHE_MASTER
|
||||||
tryPullForCache $NODE_BUILD_CACHE &
|
|
||||||
tryPullForCache $NODE_BUILD_CACHE_MASTER &
|
|
||||||
wait
|
wait
|
||||||
|
|
||||||
export DOCKER_BUILD_OPTIONS=${CACHE_FROM}
|
export DOCKER_BUILD_OPTIONS=${CACHE_FROM}
|
||||||
|
Loading…
Reference in New Issue
Block a user