(dockerfile: Dockerfile, buildArgs: Record<string, string>, target: string | undefined, globalBuildxPlatformArgs: Record<string, string> = {})
| 101 | } |
| 102 | |
| 103 | export 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 | |
| 122 | function extractDirectives(preambleStr: string) { |
| 123 | const map: Record<string, string> = {}; |
no test coverage detected