Skip to content

Commit

Permalink
Only use --cache-from if image was pulled.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed May 3, 2020
1 parent 20e6574 commit a4c1f45
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions build-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ run() {
local image_name="rustembedded/cross:${1}"
local cache_from_args=

if docker image inspect "${image_name}" &>/dev/null || docker pull "${image_name}"; then
cache_from_args=(--cache-from "${image_name}")
if ! docker image inspect "${image_name}" &>/dev/null; then
if docker pull "${image_name}"; then
cache_from_args=(--cache-from "${image_name}")
fi
fi

docker build ${cache_from_args[@]} --pull -t "${image_name}" -f "${dockerfile}" .
Expand Down

0 comments on commit a4c1f45

Please sign in to comment.