Skip to content

Commit

Permalink
Adopt additional_contexts in compose (microsoft/vscode-remote-release…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Dec 12, 2023
1 parent a48200c commit 09e9821
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/spec-node/dockerCompose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ export async function buildAndExtendDockerCompose(configWithRaw: SubstitutedConf
}

// determine whether we need to extend with features
const noBuildKitParams = { ...params, buildKitVersion: undefined }; // skip BuildKit -> can't set additional build contexts with compose
const extendImageBuildInfo = await getExtendImageBuildInfo(noBuildKitParams, configWithRaw, baseName, imageBuildInfo, composeService.user, additionalFeatures, canAddLabelsToContainer);
const version = parseVersion((await params.dockerComposeCLI()).version);
const supportsAdditionalBuildContexts = version && !isEarlierVersion(version, [2, 17, 0]);
const optionalBuildKitParams = supportsAdditionalBuildContexts ? params : { ...params, buildKitVersion: undefined };
const extendImageBuildInfo = await getExtendImageBuildInfo(optionalBuildKitParams, configWithRaw, baseName, imageBuildInfo, composeService.user, additionalFeatures, canAddLabelsToContainer);

let overrideImageName: string | undefined;
let buildOverrideContent = '';
Expand Down Expand Up @@ -229,6 +231,13 @@ export async function buildAndExtendDockerCompose(configWithRaw: SubstitutedConf
buildOverrideContent += ` - ${buildArg}=${featureBuildInfo.buildArgs[buildArg]}\n`;
}
}

if (Object.keys(featureBuildInfo.buildKitContexts).length > 0) {
buildOverrideContent += ' additional_contexts:\n';
for (const buildKitContext in featureBuildInfo.buildKitContexts) {
buildOverrideContent += ` - ${buildKitContext}=${featureBuildInfo.buildKitContexts[buildKitContext]}\n`;
}
}
}

// Generate the docker-compose override and build
Expand Down

0 comments on commit 09e9821

Please sign in to comment.