Fix usage of livepush v3 features

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2020-05-11 18:35:24 +01:00
parent aff5cd9b0d
commit 4e50d08f7b
3 changed files with 28 additions and 1 deletions

View File

@ -244,6 +244,7 @@ export async function makeBuildTasks(
logger: Logger,
projectName: string,
releaseHash: string = 'unavailable',
preprocessHook?: (dockerfile: string) => string,
): Promise<MultiBuild.BuildTask[]> {
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<MultiBuild.BuildTask[]> {
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.

View File

@ -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 },
);

View File

@ -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) => {