From 4e50d08f7be174b23a470e4d9d38057763f329ba Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Mon, 11 May 2020 18:35:24 +0100 Subject: [PATCH] Fix usage of livepush v3 features Change-type: patch Signed-off-by: Cameron Diver --- lib/utils/compose_ts.ts | 11 ++++++++++- lib/utils/device/deploy.ts | 14 ++++++++++++++ lib/utils/device/live.ts | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/utils/compose_ts.ts b/lib/utils/compose_ts.ts index 4d9a9453..47847b8c 100644 --- a/lib/utils/compose_ts.ts +++ b/lib/utils/compose_ts.ts @@ -244,6 +244,7 @@ export async function makeBuildTasks( logger: Logger, projectName: string, releaseHash: string = 'unavailable', + preprocessHook?: (dockerfile: string) => string, ): Promise { const buildTasks = await MultiBuild.splitBuildStream(composition, tarStream); @@ -262,7 +263,13 @@ export async function makeBuildTasks( `Resolving services with [${deviceInfo.deviceType}|${deviceInfo.arch}]`, ); - await performResolution(buildTasks, deviceInfo, projectName, releaseHash); + await performResolution( + buildTasks, + deviceInfo, + projectName, + releaseHash, + preprocessHook, + ); logger.logDebug('Found project types:'); _.each(buildTasks, task => { @@ -281,6 +288,7 @@ async function performResolution( deviceInfo: DeviceInfo, appName: string, releaseHash: string, + preprocessHook?: (dockerfile: string) => string, ): Promise { const { cloneTarStream } = require('tar-utils'); @@ -294,6 +302,7 @@ async function performResolution( BALENA_RELEASE_HASH: releaseHash, BALENA_APP_NAME: appName, }, + preprocessHook, ); // Do one task at a time (Bluebird.each instead of Bluebird.all) // in order to reduce peak memory usage. Resolves to buildTasks. diff --git a/lib/utils/device/deploy.ts b/lib/utils/device/deploy.ts index 6acfccc6..322209d3 100644 --- a/lib/utils/device/deploy.ts +++ b/lib/utils/device/deploy.ts @@ -309,6 +309,13 @@ export async function performBuilds( logger, LOCAL_APPNAME, LOCAL_RELEASEHASH, + content => { + if (!opts.nolive) { + return LivepushManager.preprocessDockerfile(content); + } else { + return content; + } + }, ); logger.logDebug('Probing remote daemon for cache images'); @@ -403,6 +410,13 @@ export async function rebuildSingleTask( logger, LOCAL_APPNAME, LOCAL_RELEASEHASH, + content => { + if (!opts.nolive) { + return LivepushManager.preprocessDockerfile(content); + } else { + return content; + } + }, ), { serviceName }, ); diff --git a/lib/utils/device/live.ts b/lib/utils/device/live.ts index 693febab..bb73d884 100644 --- a/lib/utils/device/live.ts +++ b/lib/utils/device/live.ts @@ -208,6 +208,10 @@ export class LivepushManager { }); } + public static preprocessDockerfile(content: string): string { + return new Dockerfile(content).generateLiveDockerfile(); + } + private static getMultistageImageIDs(buildLogs: BuildLogs): StageImageIDs { const stageIds: StageImageIDs = {}; _.each(buildLogs, (log, serviceName) => {