@vercel/container 26.0.1 → 26.1.0-snapshot-f90d5a1ebf99

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/index.js CHANGED
@@ -1657,7 +1657,7 @@ var import_tar = require("tar");
1657
1657
 
1658
1658
  // src/buildpacks/distribution.json
1659
1659
  var distribution_default = {
1660
- $comment: "Pinned lifecycle and buildpack archives",
1660
+ $comment: "Pinned lifecycle and buildpack archives, and buildpack images",
1661
1661
  baseUrl: "https://lwnhvkbwb2b5igkl.public.blob.vercel-storage.com",
1662
1662
  lifecycle: {
1663
1663
  version: "0.21.18",
@@ -1679,6 +1679,17 @@ var distribution_default = {
1679
1679
  version: "0.5.0",
1680
1680
  sha256: "f0f038437829d45077c8ad31060cd2274b80c3c55acfbe00ca937ea7dddfad5c"
1681
1681
  }
1682
+ },
1683
+ images: {
1684
+ registry: "vcr.vercel.com/vercel/buildpacks",
1685
+ tag: "98820ec-16-11-2026",
1686
+ digests: {
1687
+ "go-build": "sha256:c2f54d95d989e32f18a832e76764746aade4bec309c9ff37f88e15318861fa98",
1688
+ "go-build-static": "sha256:a957e79300c3be3131b6d2a3a84daf87ba3da7e368efff23d70909b79bebb50d",
1689
+ "rust-build": "sha256:88b1246b2b19c51d143ce97805b0c071859e84c29f4117508b20b12d03eb7358",
1690
+ run: "sha256:d38ee165eca54695d356e3784e5a3aced284528bba3b9f791acee8c094e4b2e7",
1691
+ "run-static": "sha256:4df0ab716f051a036a8ccb3a3d8f97a4606aa3ec912ad5685acb2ee348b05a40"
1692
+ }
1682
1693
  }
1683
1694
  };
1684
1695
 
@@ -1686,6 +1697,17 @@ var distribution_default = {
1686
1697
  var distribution = distribution_default;
1687
1698
  var BUILDPACK_DIST_BASE_URL = distribution.baseUrl;
1688
1699
  var LIFECYCLE_VERSION = distribution.lifecycle.version;
1700
+ function buildpackImage(name) {
1701
+ const { registry, digests } = distribution.images;
1702
+ return `${registry}/${name}@${digests[name]}`;
1703
+ }
1704
+ var BUILDPACK_IMAGES = {
1705
+ goBuild: buildpackImage("go-build"),
1706
+ goBuildStatic: buildpackImage("go-build-static"),
1707
+ rustBuild: buildpackImage("rust-build"),
1708
+ run: buildpackImage("run"),
1709
+ runStatic: buildpackImage("run-static")
1710
+ };
1689
1711
  var LIFECYCLE = {
1690
1712
  url: `${BUILDPACK_DIST_BASE_URL}/lifecycle/${LIFECYCLE_VERSION}/lifecycle-v${LIFECYCLE_VERSION}-linux-x86-64.tgz`,
1691
1713
  sha256: distribution.lifecycle.sha256
@@ -2445,7 +2467,7 @@ async function addBuildUserThroughMount(buildContainer, client) {
2445
2467
  async function prepareBuildContainer(buildContainer, buildpack, params, client) {
2446
2468
  const start = Date.now();
2447
2469
  step(
2448
- `Preparing ${buildpack.runtime} ${params.image.version} stock image and Vercel buildpacks`
2470
+ `Preparing ${buildpack.runtime} ${params.image.version} build image and Vercel buildpacks`
2449
2471
  );
2450
2472
  const usage = await BuildahImageUsage.begin();
2451
2473
  await client.run([
@@ -2553,12 +2575,19 @@ async function buildAndPushWithLifecycle(buildpack, params, client, span) {
2553
2575
  buildCommand: params.buildCommand
2554
2576
  });
2555
2577
  const registrySetup = params.prepareRegistry?.();
2556
- const containerReady = prepareBuildContainer(
2557
- buildContainer,
2558
- buildpack,
2559
- params,
2560
- client
2561
- );
2578
+ const containerReady = (async () => {
2579
+ if (params.image.buildImage.startsWith(
2580
+ `${params.credentials.registry}/`
2581
+ )) {
2582
+ await registrySetup;
2583
+ }
2584
+ await prepareBuildContainer(
2585
+ buildContainer,
2586
+ buildpack,
2587
+ params,
2588
+ client
2589
+ );
2590
+ })();
2562
2591
  const [registry, container, distribution2, cacheCopy] = await Promise.allSettled([
2563
2592
  registrySetup,
2564
2593
  containerReady,
@@ -2710,12 +2739,13 @@ function localBuildImageDockerfile(buildImage, nodeMajor) {
2710
2739
  `FROM docker.io/library/node:${nodeMajor}-bookworm-slim AS node`
2711
2740
  );
2712
2741
  }
2713
- lines.push(`FROM ${buildImage}`);
2742
+ lines.push(`FROM ${buildImage}`, "USER 0:0");
2714
2743
  if (nodeMajor !== void 0) {
2715
2744
  lines.push(`COPY --from=node /usr/local /node${nodeMajor}`);
2716
2745
  }
2717
2746
  lines.push(
2718
- `RUN groupadd --gid ${BUILD_GROUP_ID} cnb && useradd --create-home --uid ${BUILD_USER_ID} --gid ${BUILD_GROUP_ID} cnb && mkdir -p /layers /platform /workspace && chown -R ${BUILD_USER} /layers /workspace /home/cnb`
2747
+ `RUN if ! id cnb >/dev/null 2>&1; then groupadd --gid ${BUILD_GROUP_ID} cnb && useradd --create-home --uid ${BUILD_USER_ID} --gid ${BUILD_GROUP_ID} cnb; fi && test "$(id -u cnb):$(id -g cnb)" = "${BUILD_USER}" && mkdir -p /layers /platform /workspace && chown -R ${BUILD_USER} /layers /workspace /home/cnb`,
2748
+ `USER ${BUILD_USER}`
2719
2749
  );
2720
2750
  return `${lines.join("\n")}
2721
2751
  `;
@@ -2976,10 +3006,7 @@ var import_node_path18 = require("path");
2976
3006
  var import_node_fs10 = require("fs");
2977
3007
  var import_node_path15 = require("path");
2978
3008
  var DEFAULT_GO_VERSION = "1";
2979
- var GO_IMAGE_REPOSITORY = "docker.io/library/golang";
2980
- var GO_BUILD_IMAGE_DISTRO = "bookworm";
2981
- var GO_RUN_IMAGE = "gcr.io/distroless/cc-debian12@sha256:6dc8478fd8e790ae427aeff51e588573dec83b13adb7e5d10505a717927009b5";
2982
- var OLDEST_IMAGE_MINOR = 21;
3009
+ var OLDEST_TOOLCHAIN_MINOR = 21;
2983
3010
  var GO_CANDIDATE_ENTRYPOINTS = [
2984
3011
  "main.go",
2985
3012
  "cmd/api/main.go",
@@ -2994,7 +3021,7 @@ function parseImageVersion(value) {
2994
3021
  const parts = value.split(".").map(Number);
2995
3022
  if (!parts.every(Number.isSafeInteger))
2996
3023
  return void 0;
2997
- if (parts[0] > 1 || parts[0] === 1 && parts[1] >= OLDEST_IMAGE_MINOR) {
3024
+ if (parts[0] > 1 || parts[0] === 1 && parts[1] >= OLDEST_TOOLCHAIN_MINOR) {
2998
3025
  return { tag: value, parts: [parts[0], parts[1], parts[2] ?? 0] };
2999
3026
  }
3000
3027
  return void 0;
@@ -3018,12 +3045,12 @@ var go = {
3018
3045
  runtime: "go",
3019
3046
  projectMarkers: ["go.mod"],
3020
3047
  buildpacks: [vercelBuildpack("go")],
3021
- async resolveImage(workPath) {
3022
- const version2 = selectGoVersion(workPath);
3048
+ async resolveImage(workPath, buildEnv) {
3049
+ const cgo = buildEnv?.CGO_ENABLED === "1";
3023
3050
  return {
3024
- version: version2,
3025
- buildImage: `${GO_IMAGE_REPOSITORY}:${version2}-${GO_BUILD_IMAGE_DISTRO}`,
3026
- runImage: GO_RUN_IMAGE
3051
+ version: selectGoVersion(workPath),
3052
+ buildImage: cgo ? BUILDPACK_IMAGES.goBuild : BUILDPACK_IMAGES.goBuildStatic,
3053
+ runImage: cgo ? BUILDPACK_IMAGES.run : BUILDPACK_IMAGES.runStatic
3027
3054
  };
3028
3055
  },
3029
3056
  defaultEntrypoint({ workPath, zeroConfig }) {
@@ -3137,9 +3164,6 @@ var import_node_fs12 = require("fs");
3137
3164
  var import_node_path17 = require("path");
3138
3165
  var import_smol_toml3 = require("smol-toml");
3139
3166
  var DEFAULT_RUST_VERSION = "1";
3140
- var RUST_IMAGE_REPOSITORY = "docker.io/library/rust";
3141
- var RUST_BUILD_IMAGE_DISTRO = "bookworm";
3142
- var RUST_RUN_IMAGE = "gcr.io/distroless/cc-debian12@sha256:6dc8478fd8e790ae427aeff51e588573dec83b13adb7e5d10505a717927009b5";
3143
3167
  var RUST_TOOLCHAIN_FILES = ["rust-toolchain", "rust-toolchain.toml"];
3144
3168
  var rust = {
3145
3169
  runtime: "rust",
@@ -3149,8 +3173,8 @@ var rust = {
3149
3173
  const version2 = selectRustVersion(workPath) ?? DEFAULT_RUST_VERSION;
3150
3174
  return {
3151
3175
  version: version2,
3152
- buildImage: `${RUST_IMAGE_REPOSITORY}:${version2}-${RUST_BUILD_IMAGE_DISTRO}`,
3153
- runImage: RUST_RUN_IMAGE
3176
+ buildImage: BUILDPACK_IMAGES.rustBuild,
3177
+ runImage: BUILDPACK_IMAGES.run
3154
3178
  };
3155
3179
  },
3156
3180
  defaultEntrypoint({ workPath, zeroConfig }) {
@@ -3258,7 +3282,7 @@ async function buildAndPushBuildpack(params) {
3258
3282
  const commands = selectCommands(params);
3259
3283
  const prereleaseUrl = getPrereleaseUrl();
3260
3284
  const buildpack = prereleaseUrl ? await withPrereleaseBuildpack(params.buildpack, prereleaseUrl) : params.buildpack;
3261
- const image = await buildpack.resolveImage(sourceDir);
3285
+ const image = await buildpack.resolveImage(sourceDir, params.buildEnv);
3262
3286
  const nodeToolchain = engine.name === "buildah" ? await resolveNodeToolchain(sourceDir, params.config, params.meta) : await resolveLocalNodeToolchain(
3263
3287
  sourceDir,
3264
3288
  params.config,
@@ -4332,6 +4356,9 @@ async function resolveImageHandler(options, source, buildahClient, span, schedul
4332
4356
  "container.repository": repository2,
4333
4357
  "image.tag": tag2
4334
4358
  });
4359
+ const buildEnv = buildArgsFromEnv(
4360
+ meta?.buildEnv ?? (buildpack.runtime === "go" ? { CGO_ENABLED: process.env.CGO_ENABLED } : void 0)
4361
+ );
4335
4362
  try {
4336
4363
  return await buildAndPushBuildpack({
4337
4364
  buildpack,
@@ -4343,7 +4370,7 @@ async function resolveImageHandler(options, source, buildahClient, span, schedul
4343
4370
  tag: tag2,
4344
4371
  config,
4345
4372
  meta,
4346
- buildEnv: buildArgsFromEnv(meta?.buildEnv),
4373
+ buildEnv,
4347
4374
  buildahClient,
4348
4375
  parentSpan: span
4349
4376
  });
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/container",
3
- "version": "26.0.1",
3
+ "version": "26.1.0-snapshot-f90d5a1ebf99",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://vercel.com/docs",
@@ -17,13 +17,13 @@
17
17
  "tar": "7.5.11"
18
18
  },
19
19
  "peerDependencies": {
20
- "@vercel/build-utils": "15.4.1"
20
+ "@vercel/build-utils": "15.4.2-snapshot-f90d5a1ebf99"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "20.11.0",
24
24
  "vitest": "4.1.10",
25
25
  "@vercel-internals/ipc-proxy": "1.1.4",
26
- "@vercel/build-utils": "15.4.1"
26
+ "@vercel/build-utils": "15.4.2-snapshot-f90d5a1ebf99"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"