MCPcopy Index your code
hub / github.com/devcontainers/cli / findBaseImage

Function findBaseImage

src/spec-node/dockerfileUtils.ts:103–120  ·  view source on GitHub ↗
(dockerfile: Dockerfile, buildArgs: Record<string, string>, target: string | undefined, globalBuildxPlatformArgs: Record<string, string> = {})

Source from the content-addressed store, hash-verified

101}
102
103export function findBaseImage(dockerfile: Dockerfile, buildArgs: Record<string, string>, target: string | undefined, globalBuildxPlatformArgs: Record<string, string> = {}) {
104 let stage: Stage | undefined = target ? dockerfile.stagesByLabel[target] : dockerfile.stages[dockerfile.stages.length - 1];
105 const seen = new Set<Stage>();
106 while (stage) {
107 if (seen.has(stage)) {
108 return undefined;
109 }
110 seen.add(stage);
111
112 const image = replaceVariables(dockerfile, buildArgs, /* not available in FROM instruction */ {}, globalBuildxPlatformArgs, stage.from.image, dockerfile.preamble, dockerfile.preamble.instructions.length);
113 const nextStage = dockerfile.stagesByLabel[image];
114 if (!nextStage) {
115 return image;
116 }
117 stage = nextStage;
118 }
119 return undefined;
120}
121
122function extractDirectives(preambleStr: string) {
123 const map: Record<string, string> = {};

Calls 1

replaceVariablesFunction · 0.85

Tested by

no test coverage detected