From a1c406a4795e3f91963676f923ca607df975a2c7 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Wed, 12 Feb 2020 11:35:03 +0000 Subject: [PATCH] Add '--cache-from' option to balena build and deploy commands It implements the same feature as the "docker build --cache-from" option. Resolves: #1616 Change-type: minor --- doc/cli.markdown | 8 ++++++++ lib/utils/docker-coffee.coffee | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/cli.markdown b/doc/cli.markdown index 1aaccd0d..76101b4f 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -1968,6 +1968,10 @@ The alias to the generated image Set a build-time variable (eg. "-B 'ARG=value'"). Can be specified multiple times. +#### --cache-from <image-list> + +Comma-separated list (no spaces) of image names for build cache resolution. Implements the same feature as the "docker build --cache-from" option. + #### --nocache Don't use docker layer caching when building @@ -2097,6 +2101,10 @@ The alias to the generated image Set a build-time variable (eg. "-B 'ARG=value'"). Can be specified multiple times. +#### --cache-from <image-list> + +Comma-separated list (no spaces) of image names for build cache resolution. Implements the same feature as the "docker build --cache-from" option. + #### --nocache Don't use docker layer caching when building diff --git a/lib/utils/docker-coffee.coffee b/lib/utils/docker-coffee.coffee index 064cb45d..e79aaa2a 100644 --- a/lib/utils/docker-coffee.coffee +++ b/lib/utils/docker-coffee.coffee @@ -83,6 +83,13 @@ exports.appendOptions = (opts) -> description: 'Set a build-time variable (eg. "-B \'ARG=value\'"). Can be specified multiple times.' alias: 'B' }, + { + signature: 'cache-from' + parameter: 'image-list' + description: ' + Comma-separated list (no spaces) of image names for build cache resolution. + Implements the same feature as the "docker build --cache-from" option.' + }, { signature: 'nocache' description: "Don't use docker layer caching when building" @@ -160,6 +167,8 @@ exports.generateBuildOpts = (options) -> opts.t = options.tag if options.nocache? opts.nocache = true + if options['cache-from']?.trim() + opts.cachefrom = options['cache-from'].split(',').filter((i) -> !!i.trim()) if options.squash? opts.squash = true if options.buildArg?