@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.
- package/dist/build-context.d.ts +7 -0
- package/dist/buildah-store-cache/cache.d.ts +30 -0
- package/dist/buildah-store-cache/cleanup.d.ts +2 -0
- package/dist/buildah-store-cache/command/index.d.ts +9 -0
- package/dist/buildah-store-cache/command/main.d.ts +1 -0
- package/dist/buildah-store-cache/command/operations.d.ts +13 -0
- package/dist/buildah-store-cache/command/types.d.ts +53 -0
- package/dist/buildah-store-cache/config.d.ts +5 -0
- package/dist/buildah-store-cache/lock.d.ts +17 -0
- package/dist/buildah-store-cache/state.d.ts +8 -0
- package/dist/buildah-store-cache/usage.d.ts +14 -0
- package/dist/buildah-store-command.js +2 -0
- package/dist/buildpacks/build.d.ts +14 -0
- package/dist/buildpacks/cache.d.ts +55 -0
- package/dist/buildpacks/distribution.d.ts +71 -0
- package/dist/buildpacks/go.d.ts +12 -0
- package/dist/buildpacks/lifecycle/build-user.d.ts +1 -0
- package/dist/buildpacks/lifecycle/buildah.d.ts +10 -0
- package/dist/buildpacks/lifecycle/docker.d.ts +19 -0
- package/dist/buildpacks/lifecycle/lifecycle.d.ts +161 -0
- package/dist/buildpacks/lifecycle/native.d.ts +58 -0
- package/dist/buildpacks/node-toolchain.d.ts +19 -0
- package/dist/buildpacks/registry.d.ts +54 -0
- package/dist/buildpacks/ruby.d.ts +25 -0
- package/dist/buildpacks/rust.d.ts +2 -0
- package/dist/buildpacks/version.d.ts +1 -0
- package/dist/clients/buildah.d.ts +31 -0
- package/dist/dev.d.ts +14 -0
- package/dist/diagnostics.d.ts +8 -0
- package/dist/engines/buildah.d.ts +10 -0
- package/dist/engines/docker.d.ts +2 -0
- package/dist/engines/index.d.ts +11 -0
- package/dist/engines/types.d.ts +79 -0
- package/dist/executable-image/index.d.ts +52 -0
- package/dist/image-source.d.ts +19 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1190 -69
- package/dist/oci-layout/index.d.ts +18 -0
- package/dist/oci-layout/layout.d.ts +38 -0
- package/dist/oci-layout/pull.d.ts +37 -0
- package/dist/oidc.d.ts +30 -0
- package/dist/prepare-cache.d.ts +7 -0
- package/dist/registry.d.ts +27 -0
- package/dist/schedules-command-dispatcher +0 -0
- package/dist/schedules-command.d.ts +11 -0
- package/dist/storage-driver.d.ts +15 -0
- package/dist/util.d.ts +102 -0
- package/package.json +6 -5
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Config, ServiceRuntime } from '@vercel/build-utils';
|
|
2
|
+
import type { PinnedBuildpack } from './distribution';
|
|
3
|
+
export interface BuildpackGroup {
|
|
4
|
+
runtime: string;
|
|
5
|
+
/** The CNB order group, in order. Each entry is fetched from the mirror. */
|
|
6
|
+
buildpacks: readonly PinnedBuildpack[];
|
|
7
|
+
}
|
|
8
|
+
export interface BuildpackRuntime extends BuildpackGroup {
|
|
9
|
+
/**
|
|
10
|
+
* Runtime slug. Project detection routes a project here by setting
|
|
11
|
+
* `config.buildpack` to this value. The buildpack detect function
|
|
12
|
+
* classifies the application from its sources.
|
|
13
|
+
*/
|
|
14
|
+
runtime: ServiceRuntime;
|
|
15
|
+
/** Any one of these files marks a project the buildpack can build. */
|
|
16
|
+
projectMarkers: readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the runtime version and complete build and run image references
|
|
19
|
+
* from the staged service sources and project build environment.
|
|
20
|
+
*/
|
|
21
|
+
resolveImage(workPath: string, buildEnv?: Record<string, string>): Promise<RuntimeImage>;
|
|
22
|
+
/**
|
|
23
|
+
* Validate the staged service sources against the project's build env
|
|
24
|
+
* before any build work begins. Throws to fail the build.
|
|
25
|
+
*/
|
|
26
|
+
validate?(params: {
|
|
27
|
+
workPath: string;
|
|
28
|
+
buildEnv?: Record<string, string>;
|
|
29
|
+
}): void;
|
|
30
|
+
/**
|
|
31
|
+
* The root-relative program to build when a service or zero-config app
|
|
32
|
+
* configures none, chosen from the staged sources as the runtime's own
|
|
33
|
+
* builder chooses it. Return `undefined` to let the buildpack discover the
|
|
34
|
+
* program, or throw to fail the build.
|
|
35
|
+
*/
|
|
36
|
+
defaultEntrypoint?(params: {
|
|
37
|
+
workPath: string;
|
|
38
|
+
zeroConfig: boolean;
|
|
39
|
+
}): string | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface RuntimeImage {
|
|
42
|
+
version: string;
|
|
43
|
+
buildImage: string;
|
|
44
|
+
runImage: string;
|
|
45
|
+
}
|
|
46
|
+
/** Every buildpack-backed runtime the container builder can select. */
|
|
47
|
+
export declare const BUILDPACKS: readonly BuildpackRuntime[];
|
|
48
|
+
/**
|
|
49
|
+
* The buildpack `config.buildpack` names, if any. This is the only selector:
|
|
50
|
+
* the platform will set it from the project's framework or the service's
|
|
51
|
+
* runtime.
|
|
52
|
+
*/
|
|
53
|
+
export declare function requestedBuildpack(config: Config | null | undefined): BuildpackRuntime | undefined;
|
|
54
|
+
export declare function hasProjectMarkers(buildpack: BuildpackRuntime, workPath: string): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BuildpackRuntime } from './registry';
|
|
2
|
+
/** Stock image tag used when a project declares no Ruby version. */
|
|
3
|
+
export declare const DEFAULT_RUBY_VERSION = "3.4";
|
|
4
|
+
/**
|
|
5
|
+
* Version files, in the order they are consulted. This is the order
|
|
6
|
+
* `ruby/setup-ruby` uses, and every file format Bundler accepts for
|
|
7
|
+
* `ruby file: ...`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const RUBY_VERSION_FILES: readonly [".ruby-version", ".tool-versions", "mise.toml"];
|
|
10
|
+
/** Vercel-owned Ruby buildpack; see `buildpacks/ruby` in vercel/buildpacks. */
|
|
11
|
+
export declare const ruby: BuildpackRuntime;
|
|
12
|
+
/**
|
|
13
|
+
* The Ruby version a service declares, or `undefined` when it declares none.
|
|
14
|
+
* The first version file present wins; the Gemfile is only read when there
|
|
15
|
+
* is none. Only the service directory is consulted, never its ancestors.
|
|
16
|
+
*/
|
|
17
|
+
export declare function selectRubyVersion(workPath: string): string | undefined;
|
|
18
|
+
/** The Ruby version in a version file; `major.minor` selects that minor's tag. */
|
|
19
|
+
export declare function parseVersionFile(name: string, contents: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* The exact Ruby version a Gemfile declares with `ruby "X.Y.Z"`, or
|
|
22
|
+
* `undefined` when it has no `ruby` line. Bundler treats `ruby "3.4"` as
|
|
23
|
+
* `= 3.4.0`, so a two-component version is completed rather than floated.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseGemfileRubyVersion(contents: string): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidVersion(version: string): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RunResult } from '../util';
|
|
2
|
+
/** Lets each command hold a lock on the image store while it runs. */
|
|
3
|
+
export interface BuildahCommandLock {
|
|
4
|
+
wrap(command: string[]): Promise<string[]>;
|
|
5
|
+
}
|
|
6
|
+
export interface BuildahRunOptions {
|
|
7
|
+
input?: string;
|
|
8
|
+
quiet?: boolean;
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
}
|
|
11
|
+
export interface BuildahStoreInfo {
|
|
12
|
+
graphRoot: string;
|
|
13
|
+
runRoot: string;
|
|
14
|
+
driver: string;
|
|
15
|
+
backingFs: string;
|
|
16
|
+
}
|
|
17
|
+
/** One build's command execution and lazily queried, stable metadata. */
|
|
18
|
+
export declare class BuildahClient {
|
|
19
|
+
private readonly lock;
|
|
20
|
+
private cachedVersion;
|
|
21
|
+
private cachedStoreInfo;
|
|
22
|
+
constructor(lock: BuildahCommandLock);
|
|
23
|
+
run(args: string[], options?: BuildahRunOptions): Promise<RunResult>;
|
|
24
|
+
/** Version checks must not open the store or acquire its lock before restore. */
|
|
25
|
+
version(): Promise<string>;
|
|
26
|
+
/** Only stable store fields are cached; image and container counts are not. */
|
|
27
|
+
info(): Promise<BuildahStoreInfo | undefined>;
|
|
28
|
+
/** Storage mismatches are diagnostic unless strict verification is requested. */
|
|
29
|
+
verifyStorage(log?: (message: string) => void): Promise<void>;
|
|
30
|
+
private readStoreInfo;
|
|
31
|
+
}
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NowBuildError, type StartDevServerOptions, type StartDevServerResult } from '@vercel/build-utils';
|
|
2
|
+
/** The error for a `docker pull` of `imageRef` that failed with `detail`. */
|
|
3
|
+
export declare function prebuiltImagePullError(imageRef: string, detail: string): NowBuildError;
|
|
4
|
+
/** Test-only: clear the reused-container caches between cases. */
|
|
5
|
+
export declare function __resetRunningContainers(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Start a container service locally for `vercel dev`, reusing an already-running
|
|
8
|
+
* container for the same service when one is live.
|
|
9
|
+
*
|
|
10
|
+
* Builds (or uses a prebuilt) image, runs it with Docker publishing the
|
|
11
|
+
* container port to an ephemeral host port, injects the service env + a `PORT`
|
|
12
|
+
* the app can honor, and returns the host port for the dev proxy to target.
|
|
13
|
+
*/
|
|
14
|
+
export declare function startDevServer(options: StartDevServerOptions): Promise<StartDevServerResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Diagnostics } from '@vercel/build-utils';
|
|
2
|
+
export declare function generateProjectManifest({ workPath, framework, serviceType, daemonName, }: {
|
|
3
|
+
workPath: string;
|
|
4
|
+
framework?: string | null;
|
|
5
|
+
serviceType?: string | null;
|
|
6
|
+
daemonName?: string;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export declare const diagnostics: Diagnostics;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BuildahClient } from '../clients/buildah';
|
|
2
|
+
import type { ContainerEngine } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Concurrent builds of the same Dockerfile step create images that differ only
|
|
5
|
+
* in timestamps, and Buildah later reuses only the newest. One epoch per
|
|
6
|
+
* deployment keeps them identical. Buildah already applies a project's own
|
|
7
|
+
* `SOURCE_DATE_EPOCH`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function deploymentSourceDateEpoch(): Promise<string | undefined>;
|
|
10
|
+
export declare function createBuildahEngine(client: BuildahClient): ContainerEngine;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BuildahClient } from '../clients/buildah';
|
|
2
|
+
import type { ContainerEngine } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Pick the container image toolchain for this environment. The Vercel build
|
|
5
|
+
* container uses buildah (daemonless); developer machines use docker.
|
|
6
|
+
*
|
|
7
|
+
* Override with `VERCEL_CONTAINER_ENGINE=docker|buildah` for testing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function selectContainerEngine(client: BuildahClient): ContainerEngine;
|
|
10
|
+
export type { BuildPushParams, ContainerEngine } from './types';
|
|
11
|
+
export { VCR_REGISTRY, TARGET_PLATFORM } from './types';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Span } from '@vercel/build-utils';
|
|
2
|
+
export declare const VCR_REGISTRY: string;
|
|
3
|
+
/** Images must target linux/amd64 — the only architecture currently supported. */
|
|
4
|
+
export declare const TARGET_PLATFORM = "linux/amd64";
|
|
5
|
+
export declare const DIGEST_RE: RegExp;
|
|
6
|
+
/** Build `--build-arg KEY=VALUE` flags from the params' project build env. */
|
|
7
|
+
export declare function buildArgFlags(params: {
|
|
8
|
+
buildArgs?: Record<string, string>;
|
|
9
|
+
}): string[];
|
|
10
|
+
/** Build `--target STAGE` flags from the params' Dockerfile stage. */
|
|
11
|
+
export declare function buildTargetFlags(params: {
|
|
12
|
+
buildTarget?: string;
|
|
13
|
+
}): string[];
|
|
14
|
+
/**
|
|
15
|
+
* The subset of {@link BuildPushParams} needed to authenticate to a registry,
|
|
16
|
+
* for callers with no Dockerfile or build context (the buildpack path).
|
|
17
|
+
*/
|
|
18
|
+
export interface RegistryCredentials {
|
|
19
|
+
registry: string;
|
|
20
|
+
username: string;
|
|
21
|
+
token: string;
|
|
22
|
+
}
|
|
23
|
+
export interface BuildPushParams extends RegistryCredentials {
|
|
24
|
+
contextDir: string;
|
|
25
|
+
dockerfilePath: string;
|
|
26
|
+
imageRef: string;
|
|
27
|
+
/** Bare repository name (without team/project prefix), for error messages. */
|
|
28
|
+
repository: string;
|
|
29
|
+
/**
|
|
30
|
+
* Project build env (from `meta.buildEnv`) forwarded to the image build as
|
|
31
|
+
* `--build-arg KEY=VALUE`, so Dockerfiles can consume declared `ARG`s during
|
|
32
|
+
* build — matching how other builders run build steps with the build env.
|
|
33
|
+
* Only the project's build env is included, never the build container's own
|
|
34
|
+
* internal environment.
|
|
35
|
+
*/
|
|
36
|
+
buildArgs?: Record<string, string>;
|
|
37
|
+
/** Dockerfile stage to build (`--target`); defaults to the last stage. */
|
|
38
|
+
buildTarget?: string;
|
|
39
|
+
/** Restored store images need fresh base images and one shared local tag. */
|
|
40
|
+
useBuildahStoreCache?: boolean;
|
|
41
|
+
/** The Dockerfile's base image was just built and isn't in a registry yet. */
|
|
42
|
+
baseImageIsLocal?: boolean;
|
|
43
|
+
span?: Span;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pluggable container image toolchain. Docker is used on developer machines;
|
|
47
|
+
* buildah is used in the Vercel build container (daemonless, smaller footprint).
|
|
48
|
+
*/
|
|
49
|
+
export interface ContainerEngine {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
/** Verify the toolchain is installed and usable before build/login/push. */
|
|
52
|
+
ensureReady(span?: Span): Promise<void>;
|
|
53
|
+
/** Best-effort diagnostics; must not fail the build. */
|
|
54
|
+
logDiagnostics(span?: Span): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Prepare the runtime environment (e.g. start dockerd). No-op for daemonless
|
|
57
|
+
* engines. The callback runs build/login/push inside this scope.
|
|
58
|
+
*/
|
|
59
|
+
withRuntime<T>(span: Span | undefined, fn: () => Promise<T>): Promise<T>;
|
|
60
|
+
/** Build the image and return the local reference it was tagged with. */
|
|
61
|
+
build(params: BuildPushParams): Promise<string>;
|
|
62
|
+
/** ONBUILD triggers kept in a built image. Buildah's OCI images drop them. */
|
|
63
|
+
onBuildTriggers?(imageRef: string): Promise<string[]>;
|
|
64
|
+
login(params: RegistryCredentials): Promise<void>;
|
|
65
|
+
/** Push the image and return the digest of the manifest the registry stored. */
|
|
66
|
+
push(params: BuildPushParams): Promise<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Verify the engine's storage is configured as intended (e.g. native overlay
|
|
69
|
+
* on the mounted cell volume) before building. MAY throw to fail the build
|
|
70
|
+
* fast when storage is misconfigured. Runs before build/login/push.
|
|
71
|
+
*/
|
|
72
|
+
verifyStorage?(span?: Span): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Best-effort report of the engine's effective on-disk image store (graph
|
|
75
|
+
* root, run root, driver, backing filesystem). Used to confirm the build is
|
|
76
|
+
* using the mounted cell storage volume. Must not fail the build.
|
|
77
|
+
*/
|
|
78
|
+
reportStorage?(span?: Span): Promise<void>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Span } from '@vercel/build-utils';
|
|
2
|
+
import { fetchDistribution } from '../buildpacks/lifecycle/lifecycle';
|
|
3
|
+
import { type BuildUser } from '../buildpacks/lifecycle/native';
|
|
4
|
+
import { type ImageOutput } from '../oci-layout';
|
|
5
|
+
import { ensureRepository, resolveRegistryTarget } from '../registry';
|
|
6
|
+
import { type run } from '../util';
|
|
7
|
+
export type ExecutableImage = ImageOutput;
|
|
8
|
+
export interface ExecutableImageBuilderOptions {
|
|
9
|
+
/** Repository within the project's registry namespace, used when pushing. */
|
|
10
|
+
repository: string;
|
|
11
|
+
env?: NodeJS.ProcessEnv;
|
|
12
|
+
span?: Span;
|
|
13
|
+
}
|
|
14
|
+
export interface BuildExecutableImageOptions {
|
|
15
|
+
executablePath: string;
|
|
16
|
+
/** Where to write the OCI layout when the layout flag is on. */
|
|
17
|
+
layoutDir: string;
|
|
18
|
+
}
|
|
19
|
+
/** Test overrides for what `create` uses. Each defaults to the real one. */
|
|
20
|
+
export interface ExecutableImageBuilderDeps {
|
|
21
|
+
platform?: NodeJS.Platform;
|
|
22
|
+
arch?: string;
|
|
23
|
+
registry?: string;
|
|
24
|
+
runImage?: string;
|
|
25
|
+
registryBaseUrl?: string;
|
|
26
|
+
fetchImpl?: typeof fetch;
|
|
27
|
+
resolveBuildUser?: () => Promise<BuildUser>;
|
|
28
|
+
resolveStagingParent?: () => Promise<string>;
|
|
29
|
+
fetchDistribution?: typeof fetchDistribution;
|
|
30
|
+
resolveRegistryTarget?: typeof resolveRegistryTarget;
|
|
31
|
+
ensureRepository?: typeof ensureRepository;
|
|
32
|
+
runCommand?: typeof run;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Packages static linux/amd64 executables as container images on `run-static`
|
|
36
|
+
* using the native CNB lifecycle.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ExecutableImageBuilder {
|
|
39
|
+
private readonly sharedRoot;
|
|
40
|
+
private readonly runner;
|
|
41
|
+
private readonly mode;
|
|
42
|
+
private readonly span?;
|
|
43
|
+
private closed;
|
|
44
|
+
private constructor();
|
|
45
|
+
/** Fetches the lifecycle and buildpack, and in layout mode pulls run-static. */
|
|
46
|
+
static create(options: ExecutableImageBuilderOptions, deps?: ExecutableImageBuilderDeps): Promise<ExecutableImageBuilder>;
|
|
47
|
+
/** Packages one static linux/amd64 executable as an image. */
|
|
48
|
+
build(executable: BuildExecutableImageOptions): Promise<ExecutableImage>;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
private exportLayout;
|
|
51
|
+
private push;
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BuildOptions } from '@vercel/build-utils';
|
|
2
|
+
import type { BuildpackRuntime } from './buildpacks/registry';
|
|
3
|
+
/**
|
|
4
|
+
* Where the container image for a service comes from. Shared by the build and
|
|
5
|
+
* dev paths so `vercel build` and `vercel dev` always agree.
|
|
6
|
+
*/
|
|
7
|
+
export type ImageSource = {
|
|
8
|
+
kind: 'dockerfile';
|
|
9
|
+
/** Relative to `workPath`; may not exist when named explicitly. */
|
|
10
|
+
dockerfileRel: string;
|
|
11
|
+
dockerfilePath: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'prebuilt';
|
|
14
|
+
imageRef: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'buildpack';
|
|
17
|
+
buildpack: BuildpackRuntime;
|
|
18
|
+
};
|
|
19
|
+
export declare function resolveImageSource(options: Pick<BuildOptions, 'config' | 'workPath' | 'entrypoint'>, context: 'build' | 'dev'): ImageSource;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BuildOptions, BuildResultV2 } from '@vercel/build-utils';
|
|
2
|
+
export declare const version = 2;
|
|
3
|
+
/**
|
|
4
|
+
* Output path for the container function.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately not `index`: the filesystem handler resolves `/` to an `index`
|
|
7
|
+
* output, so a rewrite landing on `/` would dispatch there before the catch-all
|
|
8
|
+
* can copy the resolved destination into the runtime request path.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CONTAINER_OUTPUT_PATH = "container";
|
|
11
|
+
export { startDevServer } from './dev';
|
|
12
|
+
export { prepareCache } from './prepare-cache';
|
|
13
|
+
export { diagnostics } from './diagnostics';
|
|
14
|
+
export { ExecutableImageBuilder, type BuildExecutableImageOptions, type ExecutableImage, type ExecutableImageBuilderOptions, } from './executable-image';
|
|
15
|
+
export declare function build(options: BuildOptions): Promise<BuildResultV2>;
|