@vercel/container 30.0.0 → 31.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import type { BuildOptions, Span } from '@vercel/build-utils';
2
2
  import type { BuildahClient } from '../clients/buildah';
3
+ import type { ImageOutput } from '../oci-layout';
3
4
  import type { BuildpackRuntime } from './registry';
4
5
  type BuildpackBuildParams = Pick<BuildOptions, 'files' | 'workPath' | 'repoRootPath' | 'service' | 'config' | 'meta'> & {
5
6
  buildpack: BuildpackRuntime;
@@ -8,7 +9,8 @@ type BuildpackBuildParams = Pick<BuildOptions, 'files' | 'workPath' | 'repoRootP
8
9
  buildEnv?: Record<string, string>;
9
10
  parentSpan?: Span;
10
11
  buildahClient: BuildahClient;
12
+ exportLayout?: boolean;
11
13
  };
12
- /** Stage the service, run its buildpacks, and return the published image reference. */
13
- export declare function buildAndPushBuildpack(params: BuildpackBuildParams): Promise<string>;
14
+ /** Stage the service, run its buildpacks, and return the built image output. */
15
+ export declare function buildBuildpackImage(params: BuildpackBuildParams): Promise<ImageOutput>;
14
16
  export {};
@@ -1,3 +1,4 @@
1
+ import type { RegistryCredentials } from '../engines/types';
1
2
  import type { BuildpackRuntime } from './registry';
2
3
  export interface PinnedArchive {
3
4
  url: string;
@@ -55,6 +56,8 @@ export declare const BUILDPACK_IMAGES: {
55
56
  readonly run: string;
56
57
  readonly runStatic: string;
57
58
  };
59
+ export declare const BUILDPACK_IMAGE_REGISTRY: string;
60
+ export declare function buildpackImageCredentials(identity: Pick<RegistryCredentials, 'username' | 'token'>): RegistryCredentials;
58
61
  /**
59
62
  * The CNB lifecycle binary, shared by every buildpack.
60
63
  */
@@ -1,10 +1,10 @@
1
1
  import type { Span } from '@vercel/build-utils';
2
2
  import type { BuildahClient } from '../../clients/buildah';
3
3
  import type { BuildpackRuntime } from '../registry';
4
- import type { LifecycleRegistryBuildParams, LifecycleRegistryBuildResult } from './lifecycle';
4
+ import type { LifecycleBuildParams, LifecycleOutput } from './lifecycle';
5
5
  /**
6
6
  * Build and publish a buildpack service with buildah — the Vercel build
7
7
  * container path. The docker counterpart for local `vercel build` is
8
- * `buildAndPushWithLifecycleDocker`.
8
+ * `buildWithLifecycleDocker`.
9
9
  */
10
- export declare function buildAndPushWithLifecycle(buildpack: BuildpackRuntime, params: LifecycleRegistryBuildParams, client: BuildahClient, span?: Span): Promise<LifecycleRegistryBuildResult>;
10
+ export declare function buildWithLifecycle(buildpack: BuildpackRuntime, params: LifecycleBuildParams, client: BuildahClient, span?: Span): Promise<LifecycleOutput>;
@@ -1,4 +1,6 @@
1
- import type { LifecycleRunner } from './lifecycle';
1
+ import type { Span } from '@vercel/build-utils';
2
+ import type { BuildpackRuntime } from '../registry';
3
+ import type { LifecycleBuildParams, LifecycleOutput } from './lifecycle';
2
4
  /**
3
5
  * The Dockerfile for the local build image: the selected runtime image
4
6
  * with a CNB user, mirroring the setup the production build container
@@ -11,9 +13,7 @@ export declare function localBuildImageDockerfile(buildImage: string, nodeMajor?
11
13
  /** Deterministic tag so the derived image is reused until its inputs change. */
12
14
  export declare function localBuildImageTag(dockerfile: string): string;
13
15
  /**
14
- * Build and publish a buildpack service with a local docker daemon: the
15
- * docker counterpart of `buildAndPushWithLifecycle`, and the local
16
- * `vercel build` path. The creator runs in a derived stock image and exports
17
- * straight to the registry, exactly as in production.
16
+ * Build and export a buildpack service with a local docker daemon: the docker
17
+ * counterpart of `buildWithLifecycle`, and the local `vercel build` path.
18
18
  */
19
- export declare const buildAndPushWithLifecycleDocker: LifecycleRunner;
19
+ export declare function buildWithLifecycleDocker(buildpack: BuildpackRuntime, params: LifecycleBuildParams, span?: Span): Promise<LifecycleOutput>;
@@ -4,12 +4,18 @@ import type { RunError } from '../../util';
4
4
  import type { PinnedArchive } from '../distribution';
5
5
  import type { BuildpackGroup, BuildpackRuntime, RuntimeImage } from '../registry';
6
6
  import type { NodeToolchain } from '../node-toolchain';
7
- export interface LifecycleRegistryBuildParams {
7
+ export type LifecycleOutputTarget = {
8
+ kind: 'registry';
9
+ imageRef: string;
10
+ } | {
11
+ kind: 'oci-layout';
12
+ };
13
+ export interface LifecycleBuildParams {
8
14
  /** A materialized, self-contained snapshot of the filtered source files. */
9
15
  workPath: string;
10
16
  buildEnv?: Record<string, string>;
11
17
  image: RuntimeImage;
12
- imageRef: string;
18
+ output: LifecycleOutputTarget;
13
19
  /** The same credentials `engine.login()` validated. */
14
20
  credentials: RegistryCredentials;
15
21
  /** Buildah can overlap registry setup; omit if already prepared. */
@@ -31,15 +37,17 @@ export interface LifecycleRegistryBuildParams {
31
37
  dir: string;
32
38
  };
33
39
  }
34
- export interface LifecycleRegistryBuildResult {
35
- imageRef: string;
40
+ export declare function isOciLayoutTarget(target: LifecycleOutputTarget): target is {
41
+ kind: 'oci-layout';
42
+ };
43
+ export type LifecycleOutput = {
44
+ kind: 'registry';
36
45
  digest: string;
37
- buildImage: string;
38
- runImage: string;
39
- runtimeVersion: string;
40
- }
41
- /** The interface every lifecycle runner implements. */
42
- export type LifecycleRunner = (buildpack: BuildpackRuntime, params: LifecycleRegistryBuildParams, span?: Span) => Promise<LifecycleRegistryBuildResult>;
46
+ } | {
47
+ kind: 'oci-layout';
48
+ directory: string;
49
+ manifestDigest: string;
50
+ };
43
51
  export declare const BUILD_USER_ID = 1001;
44
52
  export declare const BUILD_GROUP_ID = 1001;
45
53
  export declare const BUILD_USER = "1001:1001";
@@ -50,12 +58,12 @@ export declare const BUILD_USER = "1001:1001";
50
58
  * vercel/buildpacks.
51
59
  */
52
60
  export declare const CNB_PLATFORM_API = "0.15";
53
- /** `CREATOR_KEYCHAIN_ENV` as engine `--env` flags, for a creator that runs in a container. */
54
- export declare const CREATOR_KEYCHAIN_ENV_ARGS: readonly string[];
55
61
  export declare const ORDER_MOUNT_DIR = "/platform/order";
56
62
  export declare const ORDER_FILE = "/platform/order/order.toml";
57
63
  /** The lifecycle's `-cache-dir`, a fresh writable directory per invocation. */
58
64
  export declare const CACHE_MOUNT_DIR = "/cache";
65
+ export declare const LAYOUT_MOUNT_DIR = "/layout";
66
+ export declare const LAYOUT_OUTPUT_IMAGE_REF = "localhost/app:build";
59
67
  /**
60
68
  * The exporter ships the entire app directory. Materialize only the caller's
61
69
  * filtered sources, never the live work tree or restored build caches.
@@ -101,14 +109,15 @@ export declare function lifecycleFailure(error: unknown, context: {
101
109
  workPath: string;
102
110
  span?: Span;
103
111
  }): RunError;
112
+ /** Kept distinct so runners do not wrap a pull error as a lifecycle failure. */
113
+ export declare class RunImagePullFailure extends Error {
114
+ constructor(buildpack: BuildpackGroup, runImage: string, reason: unknown);
115
+ }
116
+ export declare function pullRunImageLayout(runImage: string, credentials: RegistryCredentials, layoutDir: string, span?: Span): Promise<void>;
117
+ export declare function stageOciLayoutOutput(layoutDir: string, buildStart: number, span?: Span): Promise<Extract<LifecycleOutput, {
118
+ kind: 'oci-layout';
119
+ }>>;
104
120
  export declare function writeOrderDir(buildpack: BuildpackGroup, parentDir?: string): string;
105
- /**
106
- * The `CNB_REGISTRY_AUTH` value (CNB Platform API): a JSON map of registry to
107
- * `Authorization` header. The lifecycle exports from inside the build
108
- * container and cannot read the host engine's auth store, so the credentials
109
- * `engine.login()` validated are handed to it explicitly.
110
- */
111
- export declare function cnbRegistryAuth(credentials: RegistryCredentials): string;
112
121
  /** Where the creator exports the image it builds. */
113
122
  export type CreatorExportTarget = {
114
123
  kind: 'registry';
@@ -124,6 +133,7 @@ export type CreatorExportTarget = {
124
133
  */
125
134
  layoutDir: string;
126
135
  };
136
+ export declare function creatorExportTarget(output: LifecycleOutputTarget, credentials: RegistryCredentials): CreatorExportTarget;
127
137
  /**
128
138
  * The creator's trailing arguments and the environment its export needs. A
129
139
  * registry export authenticates through `CNB_REGISTRY_AUTH`; a layout export
@@ -133,6 +143,11 @@ export declare function creatorExport(target: CreatorExportTarget): {
133
143
  args: string[];
134
144
  env: Record<string, string>;
135
145
  };
146
+ /** Forward `CNB_REGISTRY_AUTH` via the child env so credentials stay off argv. */
147
+ export declare function creatorContainerEnv(target: CreatorExportTarget, baseEnv?: NodeJS.ProcessEnv): {
148
+ envArgs: string[];
149
+ env: NodeJS.ProcessEnv;
150
+ };
136
151
  export declare function distributionUrls(buildpack: BuildpackRuntime): {
137
152
  lifecycle: string;
138
153
  buildpacks: string[];
@@ -154,7 +169,7 @@ export declare function fetchDistribution(buildpack: BuildpackGroup, cnbDir: str
154
169
  * one, layer analysis is skipped. `-launch-cache` is not used: it only speeds
155
170
  * up daemon exports. Parallel export requires a cache directory.
156
171
  */
157
- export declare function creatorArgs(image: RuntimeImage, imageRef: string, options?: {
172
+ export declare function creatorArgs(image: RuntimeImage, target: CreatorExportTarget, options?: {
158
173
  cacheDir?: string;
159
174
  debug?: boolean;
160
175
  parallelExport?: boolean;