@vercel/container 27.0.0 → 28.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.
Files changed (48) hide show
  1. package/dist/build-context.d.ts +7 -0
  2. package/dist/buildah-store-cache/cache.d.ts +30 -0
  3. package/dist/buildah-store-cache/cleanup.d.ts +2 -0
  4. package/dist/buildah-store-cache/command/index.d.ts +9 -0
  5. package/dist/buildah-store-cache/command/main.d.ts +1 -0
  6. package/dist/buildah-store-cache/command/operations.d.ts +13 -0
  7. package/dist/buildah-store-cache/command/types.d.ts +53 -0
  8. package/dist/buildah-store-cache/config.d.ts +5 -0
  9. package/dist/buildah-store-cache/lock.d.ts +17 -0
  10. package/dist/buildah-store-cache/state.d.ts +8 -0
  11. package/dist/buildah-store-cache/usage.d.ts +14 -0
  12. package/dist/buildah-store-command.js +2 -0
  13. package/dist/buildpacks/build.d.ts +14 -0
  14. package/dist/buildpacks/cache.d.ts +55 -0
  15. package/dist/buildpacks/distribution.d.ts +71 -0
  16. package/dist/buildpacks/go.d.ts +12 -0
  17. package/dist/buildpacks/lifecycle/build-user.d.ts +1 -0
  18. package/dist/buildpacks/lifecycle/buildah.d.ts +10 -0
  19. package/dist/buildpacks/lifecycle/docker.d.ts +19 -0
  20. package/dist/buildpacks/lifecycle/lifecycle.d.ts +161 -0
  21. package/dist/buildpacks/lifecycle/native.d.ts +58 -0
  22. package/dist/buildpacks/node-toolchain.d.ts +19 -0
  23. package/dist/buildpacks/registry.d.ts +54 -0
  24. package/dist/buildpacks/ruby.d.ts +25 -0
  25. package/dist/buildpacks/rust.d.ts +2 -0
  26. package/dist/buildpacks/version.d.ts +1 -0
  27. package/dist/clients/buildah.d.ts +31 -0
  28. package/dist/dev.d.ts +14 -0
  29. package/dist/diagnostics.d.ts +8 -0
  30. package/dist/engines/buildah.d.ts +10 -0
  31. package/dist/engines/docker.d.ts +2 -0
  32. package/dist/engines/index.d.ts +11 -0
  33. package/dist/engines/types.d.ts +79 -0
  34. package/dist/executable-image/index.d.ts +52 -0
  35. package/dist/image-source.d.ts +19 -0
  36. package/dist/index.d.ts +15 -0
  37. package/dist/index.js +1190 -69
  38. package/dist/oci-layout/index.d.ts +18 -0
  39. package/dist/oci-layout/layout.d.ts +38 -0
  40. package/dist/oci-layout/pull.d.ts +37 -0
  41. package/dist/oidc.d.ts +30 -0
  42. package/dist/prepare-cache.d.ts +7 -0
  43. package/dist/registry.d.ts +27 -0
  44. package/dist/schedules-command-dispatcher +0 -0
  45. package/dist/schedules-command.d.ts +11 -0
  46. package/dist/storage-driver.d.ts +15 -0
  47. package/dist/util.d.ts +102 -0
  48. package/package.json +6 -5
@@ -0,0 +1,7 @@
1
+ /** Validate at the builder boundary, before handing local paths to an engine. */
2
+ export declare function resolveBuildContext({ repoRootPath, workPath, contextDir, dockerfilePath, }: {
3
+ repoRootPath?: string;
4
+ workPath: string;
5
+ contextDir: string;
6
+ dockerfilePath: string;
7
+ }): Promise<string>;
@@ -0,0 +1,30 @@
1
+ import type { Files, Span } from '@vercel/build-utils';
2
+ import type { BuildahClient } from '../clients/buildah';
3
+ /** Under the repository root, which the platform persists. */
4
+ export declare const BUILDAH_STORE_CACHE_DIR = ".vercel/cache/buildah-store";
5
+ /** One snapshot per project: every service shares Buildah's native image store. */
6
+ export declare class BuildahStoreCache {
7
+ private readonly repositoryRoot;
8
+ private readonly client;
9
+ static forProject(options: {
10
+ repoRootPath?: string;
11
+ workPath: string;
12
+ }, client: BuildahClient): BuildahStoreCache;
13
+ constructor(repositoryRoot: string, client: BuildahClient);
14
+ /**
15
+ * From `build()`, before a Buildah service opens the store or reads its build
16
+ * context. A service that builds nothing leaves the snapshot for a later
17
+ * deployment.
18
+ */
19
+ beforeBuild(options: {
20
+ buildsWithBuildah: boolean;
21
+ span?: Span;
22
+ }): Promise<void>;
23
+ /** From `prepareCache`, which the platform runs once every service has built. */
24
+ afterBuilds(): Promise<Files>;
25
+ restore(span?: Span): Promise<void>;
26
+ save(): Promise<Files>;
27
+ removeSnapshots(): Promise<void>;
28
+ private archivePath;
29
+ private snapshotDirectory;
30
+ }
@@ -0,0 +1,2 @@
1
+ /** The detached, shared-lock command can outlive the builder process. */
2
+ export declare function startContainerCleanup(name: string): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import type { FileLock } from '../lock';
2
+ import type { StoreCommandRequest, StoreCommandResults } from './types';
3
+ /** Both entry points are bundled into the same directory. */
4
+ export declare const STORE_COMMAND_SCRIPT: string;
5
+ export declare function storeCommand(request: StoreCommandRequest, script?: string): string[];
6
+ /** Runs a store command while holding `lock` exclusively. */
7
+ export declare function runStoreCommand<R extends Exclude<StoreCommandRequest, {
8
+ action: 'cleanup';
9
+ }>>(request: R, lock: FileLock): Promise<StoreCommandResults[R['action']]>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { CleanupOptions, ExtractOptions, RestoreOptions, RestoreResult, SaveOptions, SaveResult } from './types';
2
+ /** Callers hold command-lifetime locks: the restore gate, or the store lock. */
3
+ export declare class StoreOperations {
4
+ restore(options: RestoreOptions): Promise<RestoreResult>;
5
+ extract(options: ExtractOptions): Promise<RestoreResult>;
6
+ save(options: SaveOptions): Promise<SaveResult>;
7
+ cleanup(options: CleanupOptions): Promise<void>;
8
+ private finishPendingCleanup;
9
+ private pruneImages;
10
+ private archiveStore;
11
+ private restoreBlobInfoCache;
12
+ private stageBlobInfoCache;
13
+ }
@@ -0,0 +1,53 @@
1
+ export interface BuildahStorePaths {
2
+ graphRoot: string;
3
+ blobInfoCache: string;
4
+ }
5
+ export interface ExtractOptions extends BuildahStorePaths {
6
+ archive: string;
7
+ }
8
+ export interface RestoreOptions extends ExtractOptions {
9
+ storeLock: string;
10
+ marker: string;
11
+ }
12
+ export interface SaveOptions extends ExtractOptions {
13
+ stateDirectory: string;
14
+ threads: number;
15
+ buildahArgs: string[];
16
+ }
17
+ export interface CleanupOptions {
18
+ record: string;
19
+ buildahArgs: string[];
20
+ }
21
+ export type RestoreResult = {
22
+ status: 'hit';
23
+ bytes: number;
24
+ } | {
25
+ status: 'miss';
26
+ reason: string;
27
+ } | {
28
+ status: 'warm' | 'skipped';
29
+ };
30
+ export type SaveResult = {
31
+ status: 'saved' | 'unused';
32
+ } | {
33
+ status: 'skipped';
34
+ previous: 'saved' | 'unused' | 'failed';
35
+ };
36
+ export type StoreCommandRequest = {
37
+ action: 'restore';
38
+ options: RestoreOptions;
39
+ } | {
40
+ action: 'extract';
41
+ options: ExtractOptions;
42
+ } | {
43
+ action: 'save';
44
+ options: SaveOptions;
45
+ } | {
46
+ action: 'cleanup';
47
+ options: CleanupOptions;
48
+ };
49
+ export interface StoreCommandResults {
50
+ restore: RestoreResult;
51
+ extract: RestoreResult;
52
+ save: SaveResult;
53
+ }
@@ -0,0 +1,5 @@
1
+ export declare const BUILDAH_STORE_CACHE_FLAG = "VERCEL_BUILDAH_STORE_CACHE";
2
+ export declare function buildahStoreCacheRequested(): boolean;
3
+ /** Services coordinate through per-deployment state, which needs the deployment ID. */
4
+ export declare function buildahStoreCacheEnabled(): boolean;
5
+ export declare function deploymentId(): string | undefined;
@@ -0,0 +1,17 @@
1
+ import type { BuildahCommandLock } from '../clients/buildah';
2
+ /** A flock(1) lock file. A wrapped command holds the lock while it runs. */
3
+ export declare class FileLock {
4
+ readonly path: string;
5
+ constructor(path: string);
6
+ shared(command: string[]): string[];
7
+ exclusive(command: string[]): string[];
8
+ private wrap;
9
+ }
10
+ /**
11
+ * Buildah commands take the shared side, including in other services' builder
12
+ * processes. Restoring or saving the store takes the exclusive side.
13
+ */
14
+ export declare function buildahStoreLock(): Promise<FileLock | undefined>;
15
+ export declare const sharedBuildahStoreLock: BuildahCommandLock;
16
+ /** Test-only: forget whether flock is available. */
17
+ export declare function __resetFlockAvailability(): void;
@@ -0,0 +1,8 @@
1
+ export declare const CLEANUP_CONTAINER_RE: RegExp;
2
+ export type StateRecordSuffix = '.images' | '.cleanup';
3
+ /** Shared by every service's builder process and the later `prepareCache` calls. */
4
+ export declare function buildahStoreStateDirectory(): string;
5
+ export declare function createBuildahStoreStateDirectory(): Promise<string>;
6
+ /** Concurrent service builds each write their own record for the cache save. */
7
+ export declare function writeStateRecord(suffix: StateRecordSuffix, contents: string): Promise<string>;
8
+ export declare function listStateRecords(directory: string, suffix: StateRecordSuffix): Promise<string[]>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Image IDs from `buildah build --layers` output. Buildah writes RUN output and
3
+ * its `--> <id>` lines to one stream, so an ID can follow output that has no
4
+ * trailing newline. Buildah omits these lines when given `--iidfile`.
5
+ */
6
+ export declare function imageIdsFromBuildOutput(output: string): string[];
7
+ /** A pending record stops a cache save from pruning after an unfinished build. */
8
+ export declare class BuildahImageUsage {
9
+ private readonly path;
10
+ private constructor();
11
+ static begin(): Promise<BuildahImageUsage | undefined>;
12
+ /** A failure leaves the record pending, so the save stops instead of pruning blindly. */
13
+ record(images: () => string[] | Promise<string[]>): Promise<void>;
14
+ }
@@ -16,6 +16,8 @@ function run(cmd, args, opts = {}) {
16
16
  const child = (0, import_node_child_process.spawn)(cmd, args, {
17
17
  cwd: opts.cwd,
18
18
  env: opts.env,
19
+ ...opts.uid !== void 0 && { uid: opts.uid },
20
+ ...opts.gid !== void 0 && { gid: opts.gid },
19
21
  stdio: [opts.input !== void 0 ? "pipe" : "ignore", "pipe", "pipe"]
20
22
  });
21
23
  let stdout = "";
@@ -0,0 +1,14 @@
1
+ import type { BuildOptions, Span } from '@vercel/build-utils';
2
+ import type { BuildahClient } from '../clients/buildah';
3
+ import type { BuildpackRuntime } from './registry';
4
+ type BuildpackBuildParams = Pick<BuildOptions, 'files' | 'workPath' | 'repoRootPath' | 'service' | 'config' | 'meta'> & {
5
+ buildpack: BuildpackRuntime;
6
+ repository: string;
7
+ tag: string;
8
+ buildEnv?: Record<string, string>;
9
+ parentSpan?: Span;
10
+ buildahClient: BuildahClient;
11
+ };
12
+ /** Stage the service, run its buildpacks, and return the published image reference. */
13
+ export declare function buildAndPushBuildpack(params: BuildpackBuildParams): Promise<string>;
14
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { Span } from '@vercel/build-utils';
2
+ /** Under the repository root, which the platform persists. */
3
+ export declare const BUILDPACK_CACHE_DIR = ".vercel/cache/buildpacks";
4
+ /** The lifecycle's committed cache: its metadata plus one tar per layer. */
5
+ export declare const CNB_COMMITTED_DIR = "committed";
6
+ export declare const CNB_CACHE_METADATA_FILE = "io.buildpacks.lifecycle.cache.metadata";
7
+ /**
8
+ * The cache key of what the cache was built on; it is only reused there. The
9
+ * file keeps its original name so existing caches stay valid.
10
+ */
11
+ export declare const IMAGE_ID_FILE = "image-id";
12
+ export type BuildpackCacheRestore = {
13
+ status: 'hit';
14
+ bytes: number;
15
+ } | {
16
+ status: 'miss';
17
+ reason: string;
18
+ };
19
+ export type BuildpackCacheSave = {
20
+ status: 'saved';
21
+ bytes: number;
22
+ } | {
23
+ status: 'unchanged';
24
+ } | {
25
+ status: 'skipped';
26
+ reason: string;
27
+ };
28
+ /**
29
+ * One directory per application; the platform caches per project. Daemons
30
+ * that share a root build different executables, so each gets its own.
31
+ */
32
+ export declare function buildpackCacheDir(options: {
33
+ repoRootPath?: string;
34
+ workPath: string;
35
+ service?: {
36
+ name?: string;
37
+ };
38
+ config?: {
39
+ daemon?: {
40
+ name: string;
41
+ };
42
+ };
43
+ }): string;
44
+ /**
45
+ * Copy the saved cache into the lifecycle's private `-cache-dir` before the
46
+ * cache key is known, so the copy can overlap the build environment setup. It
47
+ * is not mounted directly: the lifecycle renames `committed/`, which the
48
+ * overlay checkout can refuse.
49
+ */
50
+ export declare function restoreBuildpackCache(dir: string, cacheKey: string | Promise<string>, cacheDir: string): Promise<BuildpackCacheRestore>;
51
+ export declare function saveBuildpackCache(dir: string, cacheKey: string, cacheDir: string): Promise<BuildpackCacheSave>;
52
+ export declare function describeRestore(outcome: BuildpackCacheRestore): string;
53
+ export declare function describeSave(outcome: BuildpackCacheSave): string;
54
+ export declare function recordRestore(span: Span | undefined, outcome: BuildpackCacheRestore, durationMs: number): void;
55
+ export declare function recordSave(span: Span | undefined, outcome: BuildpackCacheSave, durationMs: number): void;
@@ -0,0 +1,71 @@
1
+ import type { BuildpackRuntime } from './registry';
2
+ export interface PinnedArchive {
3
+ url: string;
4
+ sha256: string;
5
+ }
6
+ /** A vercel buildpack (`vercel-<name>-<version>.cnb`) from the release mirror. */
7
+ export interface PinnedBuildpack {
8
+ /** Release name and Blob path segment, e.g. `ruby`. */
9
+ name: string;
10
+ /** Buildpack id from its `buildpack.toml`, e.g. `vercel/ruby`. */
11
+ id: string;
12
+ version: string;
13
+ /** Checksum of the published `.cnb`. */
14
+ sha256: string;
15
+ /**
16
+ * Where the `.cnb` lives when it is not at the release location, e.g. a
17
+ * pre-release published from a vercel/buildpacks pull request. Releases
18
+ * leave this unset and derive the URL from `name` and `version`.
19
+ */
20
+ url?: string;
21
+ }
22
+ /** Images published by vercel/buildpacks, named by their Bake targets. */
23
+ export type BuildpackImageName = 'go-build' | 'go-build-static' | 'rust-build' | 'run' | 'run-static';
24
+ /**
25
+ * The shape of `distribution.json`. Bumps edit that file only; assigning it
26
+ * to this type checks the edit.
27
+ */
28
+ export interface Distribution {
29
+ /** Public Vercel Blob store mirroring vercel/buildpacks releases and the lifecycle. */
30
+ baseUrl: string;
31
+ lifecycle: {
32
+ version: string;
33
+ sha256: string;
34
+ };
35
+ /** Packaged buildpacks by release name (the Blob path segment). */
36
+ buildpacks: Readonly<Record<string, Omit<PinnedBuildpack, 'name'>>>;
37
+ /**
38
+ * Build and run images from a vercel/buildpacks `publish-images` run. Copy
39
+ * the digests from that run's `index.json`; the tag only records the run.
40
+ */
41
+ images: {
42
+ registry: string;
43
+ tag: string;
44
+ digests: Readonly<Record<BuildpackImageName, string>>;
45
+ };
46
+ }
47
+ export declare const distribution: Distribution;
48
+ export declare const BUILDPACK_DIST_BASE_URL: string;
49
+ export declare const LIFECYCLE_VERSION: string;
50
+ /** Digest-pinned image references for the Go and Rust buildpacks. */
51
+ export declare const BUILDPACK_IMAGES: {
52
+ readonly goBuild: string;
53
+ readonly goBuildStatic: string;
54
+ readonly rustBuild: string;
55
+ readonly run: string;
56
+ readonly runStatic: string;
57
+ };
58
+ /**
59
+ * The CNB lifecycle binary, shared by every buildpack.
60
+ */
61
+ export declare const LIFECYCLE: PinnedArchive;
62
+ export declare const PRERELEASE_URL_ENV = "VERCEL_BUILDPACK_PRERELEASE_URL";
63
+ /** The pinned release of a packaged buildpack, by release name. */
64
+ export declare function vercelBuildpack(name: string): PinnedBuildpack;
65
+ /**
66
+ * Where a vercel buildpack lives on the mirror, following the release layout
67
+ * unless the entry names its own archive URL.
68
+ */
69
+ export declare function vercelBuildpackArtifact(buildpack: PinnedBuildpack): PinnedArchive;
70
+ export declare function getPrereleaseUrl(env?: NodeJS.ProcessEnv): string | undefined;
71
+ export declare function withPrereleaseBuildpack(buildpack: BuildpackRuntime, archiveUrl: string): Promise<BuildpackRuntime>;
@@ -0,0 +1,12 @@
1
+ import type { BuildpackRuntime } from './registry';
2
+ /**
3
+ * `@vercel/go`'s standalone server entrypoints, in the order it tries them.
4
+ * A project detected as the Go preset has at least one.
5
+ */
6
+ export declare const GO_CANDIDATE_ENTRYPOINTS: readonly ["main.go", "cmd/api/main.go", "cmd/server/main.go"];
7
+ /**
8
+ * Vercel-owned Go buildpack; see `buildpacks/go` in vercel/buildpacks. It
9
+ * compiles one `main` package and launches the executable directly, without
10
+ * the IPC proxy `@vercel/go` wraps it in on Lambda.
11
+ */
12
+ export declare const go: BuildpackRuntime;
@@ -0,0 +1 @@
1
+ export declare function addBuildUser(mountPoint: string): void;
@@ -0,0 +1,10 @@
1
+ import type { Span } from '@vercel/build-utils';
2
+ import type { BuildahClient } from '../../clients/buildah';
3
+ import type { BuildpackRuntime } from '../registry';
4
+ import type { LifecycleRegistryBuildParams, LifecycleRegistryBuildResult } from './lifecycle';
5
+ /**
6
+ * Build and publish a buildpack service with buildah — the Vercel build
7
+ * container path. The docker counterpart for local `vercel build` is
8
+ * `buildAndPushWithLifecycleDocker`.
9
+ */
10
+ export declare function buildAndPushWithLifecycle(buildpack: BuildpackRuntime, params: LifecycleRegistryBuildParams, client: BuildahClient, span?: Span): Promise<LifecycleRegistryBuildResult>;
@@ -0,0 +1,19 @@
1
+ import type { LifecycleRunner } from './lifecycle';
2
+ /**
3
+ * The Dockerfile for the local build image: the selected runtime image
4
+ * with a CNB user, mirroring the setup the production build container
5
+ * performs with buildah. When the project needs Node.js for asset builds, the
6
+ * official Node image's `/usr/local` (bin/node, bin/npm and its lib tree) is
7
+ * copied to the toolchain home — build-only, since the exporter composes the
8
+ * app image from the run image and layers, never from this build image.
9
+ */
10
+ export declare function localBuildImageDockerfile(buildImage: string, nodeMajor?: number): string;
11
+ /** Deterministic tag so the derived image is reused until its inputs change. */
12
+ export declare function localBuildImageTag(dockerfile: string): string;
13
+ /**
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.
18
+ */
19
+ export declare const buildAndPushWithLifecycleDocker: LifecycleRunner;
@@ -0,0 +1,161 @@
1
+ import type { BuildOptions, Span } from '@vercel/build-utils';
2
+ import type { RegistryCredentials } from '../../engines/types';
3
+ import type { RunError } from '../../util';
4
+ import type { PinnedArchive } from '../distribution';
5
+ import type { BuildpackGroup, BuildpackRuntime, RuntimeImage } from '../registry';
6
+ import type { NodeToolchain } from '../node-toolchain';
7
+ export interface LifecycleRegistryBuildParams {
8
+ /** A materialized, self-contained snapshot of the filtered source files. */
9
+ workPath: string;
10
+ buildEnv?: Record<string, string>;
11
+ image: RuntimeImage;
12
+ imageRef: string;
13
+ /** The same credentials `engine.login()` validated. */
14
+ credentials: RegistryCredentials;
15
+ /** Buildah can overlap registry setup; omit if already prepared. */
16
+ prepareRegistry?: () => Promise<void>;
17
+ nodeToolchain?: NodeToolchain;
18
+ /** Passed to the buildpack as `VERCEL_ENTRYPOINT`. */
19
+ entrypoint?: string;
20
+ /** Passed to the buildpack as `VERCEL_COMMAND`. */
21
+ command?: string[];
22
+ /** Passed to the buildpack as `VERCEL_INSTALL_COMMAND`. */
23
+ installCommand?: string;
24
+ /** Passed to the buildpack as `VERCEL_BUILD_COMMAND`. */
25
+ buildCommand?: string;
26
+ /**
27
+ * Where this application's CNB directory cache is persisted. Absent when
28
+ * caching is disabled; the creator then runs with `-skip-restore`.
29
+ */
30
+ cache?: {
31
+ dir: string;
32
+ };
33
+ }
34
+ export interface LifecycleRegistryBuildResult {
35
+ imageRef: string;
36
+ 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>;
43
+ export declare const BUILD_USER_ID = 1001;
44
+ export declare const BUILD_GROUP_ID = 1001;
45
+ export declare const BUILD_USER = "1001:1001";
46
+ /**
47
+ * Platform API 0.15 (lifecycle 0.21.x). At least 0.14 is required for the
48
+ * restorer to bring back `launch=true, cache=true` layers from the directory
49
+ * cache when the output tag has no previous image. Must match the harness in
50
+ * vercel/buildpacks.
51
+ */
52
+ 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
+ export declare const ORDER_MOUNT_DIR = "/platform/order";
56
+ export declare const ORDER_FILE = "/platform/order/order.toml";
57
+ /** The lifecycle's `-cache-dir`, a fresh writable directory per invocation. */
58
+ export declare const CACHE_MOUNT_DIR = "/cache";
59
+ /**
60
+ * The exporter ships the entire app directory. Materialize only the caller's
61
+ * filtered sources, never the live work tree or restored build caches.
62
+ */
63
+ export declare function stageWorkspace({ files, workPath, repoRootPath, }: Pick<BuildOptions, 'files' | 'workPath'> & {
64
+ repoRootPath?: string;
65
+ }, destinationDir: string): Promise<void>;
66
+ /**
67
+ * Write the CNB platform environment. The platform API delivers user env as a
68
+ * directory of files (name = variable, content = value); the lifecycle does
69
+ * not forward its own process env to buildpacks, so `--env` would not work.
70
+ * The platform owns `VERCEL_NODE_HOME`, `VERCEL_ENTRYPOINT`, `VERCEL_COMMAND`,
71
+ * the command variables, and `VERCEL_OUTPUT_FILE` (set by the buildpack for a
72
+ * build command), so the project's build env can't set them.
73
+ */
74
+ export declare function writePlatformEnvDir(buildEnv: Record<string, string> | undefined, config: {
75
+ nodeHome?: string;
76
+ /** The root-relative program to build; without it, the buildpack discovers one. */
77
+ entrypoint?: string;
78
+ /** The default process argv, starting with the executable's name. */
79
+ command?: string[];
80
+ installCommand?: string;
81
+ buildCommand?: string;
82
+ }, parentDir?: string): string;
83
+ /**
84
+ * Read the exported image digest from the lifecycle's `report.toml`. Parsed
85
+ * as TOML so no other digest-shaped field can be mistaken for it.
86
+ */
87
+ export declare function readReportDigest(report: string): string | undefined;
88
+ /** The creator's exit code when a buildpack fails, after printing its error. */
89
+ export declare const BUILDPACK_FAILED_EXIT_CODE = 51;
90
+ export declare function describeCreatorExitCode(code: number | undefined): string | undefined;
91
+ /**
92
+ * Records a failed lifecycle run on its span and returns the error to throw.
93
+ * The error keeps the run's exit code, so callers can tell a buildpack's own
94
+ * failure.
95
+ */
96
+ export declare function lifecycleFailure(error: unknown, context: {
97
+ buildpack: BuildpackGroup;
98
+ /** How the lifecycle ran, such as `docker`. */
99
+ via: string;
100
+ buildImage?: string;
101
+ workPath: string;
102
+ span?: Span;
103
+ }): RunError;
104
+ 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
+ /** Where the creator exports the image it builds. */
113
+ export type CreatorExportTarget = {
114
+ kind: 'registry';
115
+ imageRef: string;
116
+ credentials: RegistryCredentials;
117
+ } | {
118
+ kind: 'oci-layout';
119
+ imageRef: string;
120
+ /**
121
+ * The creator's `-layout-dir`. The creator never pulls in this mode, so
122
+ * the run image must already be in this directory. The image is written
123
+ * beside it. Both sit at the path `layoutRefPath` gives their reference.
124
+ */
125
+ layoutDir: string;
126
+ };
127
+ /**
128
+ * The creator's trailing arguments and the environment its export needs. A
129
+ * registry export authenticates through `CNB_REGISTRY_AUTH`; a layout export
130
+ * needs no credentials.
131
+ */
132
+ export declare function creatorExport(target: CreatorExportTarget): {
133
+ args: string[];
134
+ env: Record<string, string>;
135
+ };
136
+ export declare function distributionUrls(buildpack: BuildpackRuntime): {
137
+ lifecycle: string;
138
+ buildpacks: string[];
139
+ };
140
+ /** Fetch a plain (optionally gzipped) tarball and extract it into `destinationDir`. */
141
+ export declare function fetchPinnedArchive(archive: PinnedArchive, destinationDir: string): Promise<void>;
142
+ /**
143
+ * Fetch a packaged buildpack (`pack buildpack package --format file`) and lay
144
+ * it out for the lifecycle. The `.cnb` is an OCI image layout whose layers
145
+ * contain `/cnb/buildpacks/<id>/<version>/...`; each layer is verified against
146
+ * its digest and extracted into `cnbDir` with the leading `cnb/` stripped.
147
+ */
148
+ export declare function fetchBuildpackage(archive: PinnedArchive, cnbDir: string): Promise<void>;
149
+ /** Fetch the lifecycle and every buildpack in the group into `cnbDir`. */
150
+ export declare function fetchDistribution(buildpack: BuildpackGroup, cnbDir: string): Promise<void>;
151
+ /**
152
+ * The creator's arguments. With a cache directory the restore phase runs
153
+ * against it and the exporter commits cached layers back into it; without
154
+ * one, layer analysis is skipped. `-launch-cache` is not used: it only speeds
155
+ * up daemon exports. Parallel export requires a cache directory.
156
+ */
157
+ export declare function creatorArgs(image: RuntimeImage, imageRef: string, options?: {
158
+ cacheDir?: string;
159
+ debug?: boolean;
160
+ parallelExport?: boolean;
161
+ }): string[];
@@ -0,0 +1,58 @@
1
+ import type { Span } from '@vercel/build-utils';
2
+ import type { RegistryCredentials } from '../../engines/types';
3
+ import { run } from '../../util';
4
+ import type { BuildpackGroup } from '../registry';
5
+ export declare const PREBUILT_STATIC_GROUP: BuildpackGroup;
6
+ export interface BuildUser {
7
+ uid: number;
8
+ gid: number;
9
+ switchUser: boolean;
10
+ }
11
+ export interface NativeBuildUserDeps {
12
+ getuid?: () => number;
13
+ getgid?: () => number;
14
+ readPasswd?: () => Promise<string>;
15
+ }
16
+ export declare function assertLinuxX64(platform?: NodeJS.Platform, arch?: string): void;
17
+ export declare function resolveNativeBuildUser(deps?: NativeBuildUserDeps): Promise<BuildUser>;
18
+ export declare function resolveStagingParent(resolveRealpath?: (path: string) => Promise<string>): Promise<string>;
19
+ export declare function chownRecursive(rootPath: string, uid: number, gid: number): Promise<void>;
20
+ export declare function verifyLaunchCommand(layersDir: string, executablePath: string): Promise<void>;
21
+ export interface NativeLifecycleRunnerOptions {
22
+ stagingParent: string;
23
+ user: BuildUser;
24
+ buildpack: BuildpackGroup;
25
+ cnbDir: string;
26
+ platformDir: string;
27
+ orderFile: string;
28
+ runImage: string;
29
+ runCommand?: typeof run;
30
+ }
31
+ export interface NativePushParams {
32
+ executablePath: string;
33
+ imageRef: string;
34
+ credentials: RegistryCredentials;
35
+ span?: Span;
36
+ }
37
+ export interface NativeLayoutParams {
38
+ executablePath: string;
39
+ outputImageRef: string;
40
+ layoutRoot: string;
41
+ span?: Span;
42
+ }
43
+ /**
44
+ * Runs the CNB `creator` directly as a child process against a prepared
45
+ * lifecycle and buildpack installation.
46
+ */
47
+ export declare class NativeLifecycleRunner {
48
+ private readonly options;
49
+ private readonly runCommand;
50
+ constructor(options: NativeLifecycleRunnerOptions);
51
+ runPush(params: NativePushParams): Promise<string>;
52
+ runLayout(params: NativeLayoutParams): Promise<void>;
53
+ /**
54
+ * Runs the creator, then `readResult` while the creator's report still
55
+ * exists, so a failure in either is reported as a lifecycle failure.
56
+ */
57
+ private execute;
58
+ }
@@ -0,0 +1,19 @@
1
+ import type { BuildOptions } from '@vercel/build-utils';
2
+ export interface NodeToolchain {
3
+ /** Directory containing `bin/node` and `bin/npm` inside the build container. */
4
+ home: string;
5
+ version: string;
6
+ major: number;
7
+ }
8
+ /**
9
+ * Resolve a Node.js toolchain from the Vercel build environment's pinned
10
+ * `/node<major>` installations, which are read-only mounted into the
11
+ * lifecycle container.
12
+ */
13
+ export declare function resolveNodeToolchain(workPath: string, config: BuildOptions['config'], meta: BuildOptions['meta']): Promise<NodeToolchain | undefined>;
14
+ /**
15
+ * Resolve a Node.js toolchain for a local docker build. No host probes: the
16
+ * docker lifecycle runner bakes `node:<major>-bookworm-slim`'s `/usr/local`
17
+ * into the derived build image at the toolchain home.
18
+ */
19
+ export declare function resolveLocalNodeToolchain(workPath: string, config: BuildOptions['config'], meta: BuildOptions['meta']): Promise<NodeToolchain | undefined>;