From 36026d855661a6266985f9dcdecdc01cde2b3b43 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Thu, 20 Jun 2019 13:54:43 +0100 Subject: [PATCH] Fix using an image more than once in a balena push Change-type: patch Signed-off-by: Cameron Diver --- lib/utils/device/deploy.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/utils/device/deploy.ts b/lib/utils/device/deploy.ts index 9f11a102..8e3e1560 100644 --- a/lib/utils/device/deploy.ts +++ b/lib/utils/device/deploy.ts @@ -315,6 +315,8 @@ export async function performBuilds( // Check for failures await inspectBuildResults(localImages); + const imagesToRemove: string[] = []; + // Now tag any external images with the correct name that they should be, // as this won't be done by resin-multibuild await Bluebird.map(localImages, async localImage => { @@ -325,10 +327,14 @@ export async function performBuilds( repo: generateImageName(localImage.serviceName), force: true, }); - await image.remove({ force: true }); + imagesToRemove.push(localImage.name!); } }); + await Bluebird.map(_.uniq(imagesToRemove), image => + docker.getImage(image).remove({ force: true }), + ); + return buildTasks; }