MCPcopy Create free account
hub / github.com/vercel/vercel / buildAndPushImage

Function buildAndPushImage

packages/container/src/index.ts:70–254  ·  view source on GitHub ↗
(params: {
  contextDir: string;
  dockerfilePath: string;
  repository: string;
  tag: string;
  buildArgs?: Record<string, string>;
  parentSpan?: Span;
})

Source from the content-addressed store, hash-verified

68}
69
70async function buildAndPushImage(params: {
71 contextDir: string;
72 dockerfilePath: string;
73 repository: string;
74 tag: string;
75 buildArgs?: Record<string, string>;
76 parentSpan?: Span;
77}): Promise<string> {
78 const { contextDir, dockerfilePath, repository, tag, buildArgs, parentSpan } =
79 params;
80 const engine = selectContainerEngine();
81
82 return withSpan(
83 parentSpan,
84 'container.build_and_push',
85 {
86 'container.engine': engine.name,
87 'container.registry': VCR_REGISTRY,
88 'container.repository': repository,
89 },
90 async buildSpan => {
91 const token = await withSpan(buildSpan, 'container.mint_oidc', {}, s =>
92 resolveOidcTokenForBuild(s)
93 );
94
95 const claims = decodeOidcClaims(token);
96 debug(`registry token: ${tokenFingerprint(token)}`);
97 debugTokenClaims('OIDC token claims', token);
98
99 const username = claims.owner_id;
100 if (!username) {
101 throw new Error(
102 'VERCEL_OIDC_TOKEN is missing the `owner_id` (team id) claim required to ' +
103 'authenticate to the container registry.'
104 );
105 }
106
107 const fullRepository = [claims.owner, claims.project, repository].join(
108 '/'
109 );
110 const imageRef = `${VCR_REGISTRY}/${fullRepository}:${tag}`;
111
112 buildSpan?.setAttributes({
113 'container.repository': fullRepository,
114 'image.tag': tag,
115 'image.ref': imageRef,
116 'registry.username': username,
117 });
118
119 return engine.withRuntime(buildSpan, async () => {
120 await withSpan(
121 buildSpan,
122 'container.ensure_toolchain_ready',
123 { 'container.engine': engine.name },
124 s => engine.ensureReady(s)
125 );
126
127 await withSpan(

Callers 1

resolveImageHandlerFunction · 0.85

Calls 15

selectContainerEngineFunction · 0.90
withSpanFunction · 0.90
resolveOidcTokenForBuildFunction · 0.90
decodeOidcClaimsFunction · 0.90
debugFunction · 0.90
tokenFingerprintFunction · 0.90
debugTokenClaimsFunction · 0.90
readStringFunction · 0.90
existingRegistryAuthFileFunction · 0.90
stepFunction · 0.90
toTagFunction · 0.90
doneFunction · 0.90

Tested by

no test coverage detected