@vercel/container 12.0.0 → 14.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 (2) hide show
  1. package/dist/index.js +226 -46
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -62,8 +62,8 @@ async function generateProjectManifest({
62
62
  var diagnostics = (0, import_build_utils.createDiagnostics)("container");
63
63
 
64
64
  // src/index.ts
65
- var import_node_fs15 = require("fs");
66
- var import_node_path15 = __toESM(require("path"));
65
+ var import_node_fs17 = require("fs");
66
+ var import_node_path17 = __toESM(require("path"));
67
67
 
68
68
  // src/util.ts
69
69
  var import_build_utils2 = require("@vercel/build-utils");
@@ -88,6 +88,9 @@ function write(line) {
88
88
  function info(message) {
89
89
  write(`\u25B2 container ${message}`);
90
90
  }
91
+ function warn(message) {
92
+ write(`\u25B2 container Warning: ${message}`);
93
+ }
91
94
  function step(message) {
92
95
  write(` \u2192 ${message}`);
93
96
  }
@@ -1206,9 +1209,9 @@ function selectContainerEngine() {
1206
1209
  }
1207
1210
 
1208
1211
  // src/buildpacks/build.ts
1209
- var import_node_fs11 = require("fs");
1212
+ var import_node_fs13 = require("fs");
1210
1213
  var import_node_os7 = require("os");
1211
- var import_node_path11 = require("path");
1214
+ var import_node_path13 = require("path");
1212
1215
 
1213
1216
  // src/buildpacks/cache.ts
1214
1217
  var import_node_crypto2 = require("crypto");
@@ -1371,6 +1374,16 @@ var distribution_default = {
1371
1374
  id: "vercel/ruby",
1372
1375
  version: "0.3.0",
1373
1376
  sha256: "7ee871c18ac1616658793d3d25639d7a1f65ade618f84c6596ef9e3f515b7202"
1377
+ },
1378
+ go: {
1379
+ id: "vercel/go",
1380
+ version: "0.1.0",
1381
+ sha256: "b605ba5f75e3873f910f1c76c14eeca5dce62f906a5d0bcee8a2b335c81d2859"
1382
+ },
1383
+ rust: {
1384
+ id: "vercel/rust",
1385
+ version: "0.1.0",
1386
+ sha256: "4817a493cda2e30f2a1adb7f121ecb77718046d114859b4146880fb2e24fb302"
1374
1387
  }
1375
1388
  }
1376
1389
  };
@@ -1520,7 +1533,7 @@ async function stageWorkspace({ files, workPath }, destinationDir) {
1520
1533
  const resolved = import_node_path5.posix.join(import_node_path5.posix.dirname(normalized), target);
1521
1534
  if (resolved === ".." || resolved.startsWith("../")) {
1522
1535
  throw new Error(
1523
- `Buildpack source symlink ${name} escapes the service root. Ruby buildpack services must be self-contained.`
1536
+ `Buildpack source symlink ${name} escapes the service root. Buildpack services must be self-contained.`
1524
1537
  );
1525
1538
  }
1526
1539
  staged[normalized] = new import_build_utils3.FileBlob({ data: target, mode: file.mode });
@@ -1547,7 +1560,7 @@ async function stageWorkspace({ files, workPath }, destinationDir) {
1547
1560
  const target = (0, import_node_path5.relative)(sourceRoot, sourceTarget).split(import_node_path5.sep).join("/");
1548
1561
  if (target === ".." || target.startsWith("../") || (0, import_node_path5.isAbsolute)(target) || !(target in staged)) {
1549
1562
  throw new Error(
1550
- `Buildpack source ${name} follows a symlink to an excluded or outside-root file. Ruby buildpack services must be self-contained.`
1563
+ `Buildpack source ${name} follows a symlink to an excluded or outside-root file. Buildpack services must be self-contained.`
1551
1564
  );
1552
1565
  }
1553
1566
  }
@@ -2330,13 +2343,108 @@ async function resolveLocalNodeToolchain(workPath, config, meta) {
2330
2343
  }
2331
2344
 
2332
2345
  // src/buildpacks/registry.ts
2333
- var import_node_fs10 = require("fs");
2334
- var import_node_path10 = require("path");
2346
+ var import_node_fs12 = require("fs");
2347
+ var import_node_path12 = require("path");
2335
2348
 
2336
- // src/buildpacks/ruby.ts
2349
+ // src/buildpacks/go.ts
2337
2350
  var import_node_fs9 = require("fs");
2338
2351
  var import_node_path9 = require("path");
2352
+ var DEFAULT_GO_VERSION = "1";
2353
+ var GO_IMAGE_REPOSITORY = "docker.io/library/golang";
2354
+ var GO_BUILD_IMAGE_DISTRO = "bookworm";
2355
+ var GO_RUN_IMAGE = "gcr.io/distroless/cc-debian12";
2356
+ var OLDEST_IMAGE_MINOR = 21;
2357
+ var GO_CANDIDATE_ENTRYPOINTS = [
2358
+ "main.go",
2359
+ "cmd/api/main.go",
2360
+ "cmd/server/main.go"
2361
+ ];
2362
+ var GO_TARGET_ENV = "VERCEL_GO_TARGET";
2363
+ var VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/;
2364
+ var GO_DIRECTIVE_RE = /^\s*go[ \t]+(\S+)[ \t]*(?:\/\/[^\r\n]*)?$/m;
2365
+ var TOOLCHAIN_DIRECTIVE_RE = /^\s*toolchain[ \t]+go(\S+)[ \t]*(?:\/\/[^\r\n]*)?$/m;
2366
+ function parseImageVersion(value) {
2367
+ if (value === void 0 || !VERSION_RE.test(value))
2368
+ return void 0;
2369
+ const parts = value.split(".").map(Number);
2370
+ if (!parts.every(Number.isSafeInteger))
2371
+ return void 0;
2372
+ if (parts[0] > 1 || parts[0] === 1 && parts[1] >= OLDEST_IMAGE_MINOR) {
2373
+ return { tag: value, parts: [parts[0], parts[1], parts[2] ?? 0] };
2374
+ }
2375
+ return void 0;
2376
+ }
2377
+ function compareImageVersions(a, b) {
2378
+ return a.parts[0] - b.parts[0] || a.parts[1] - b.parts[1] || a.parts[2] - b.parts[2];
2379
+ }
2380
+ function selectGoVersion(workPath) {
2381
+ const goMod = (0, import_node_path9.join)(workPath, "go.mod");
2382
+ if (!(0, import_node_fs9.existsSync)(goMod))
2383
+ return DEFAULT_GO_VERSION;
2384
+ const contents = (0, import_node_fs9.readFileSync)(goMod, "utf8");
2385
+ const toolchain = parseImageVersion(
2386
+ TOOLCHAIN_DIRECTIVE_RE.exec(contents)?.[1]
2387
+ );
2388
+ const minimum = parseImageVersion(GO_DIRECTIVE_RE.exec(contents)?.[1]);
2389
+ const declared = [toolchain, minimum].filter((version2) => version2 !== void 0).sort((a, b) => compareImageVersions(b, a));
2390
+ return declared[0]?.tag ?? DEFAULT_GO_VERSION;
2391
+ }
2392
+ function packageDirectory(entrypoint) {
2393
+ const path4 = entrypoint.replace(/\\/g, "/");
2394
+ if (import_node_path9.posix.isAbsolute(path4) || path4.split("/").includes("..")) {
2395
+ throw new Error(
2396
+ `Invalid Go entrypoint ${JSON.stringify(entrypoint)}: it must be a path inside the service root.`
2397
+ );
2398
+ }
2399
+ const normalized = import_node_path9.posix.normalize(path4).replace(/\/+$/, "");
2400
+ const directory = normalized.endsWith(".go") ? import_node_path9.posix.dirname(normalized) : normalized;
2401
+ return directory === "." ? "." : `./${directory}`;
2402
+ }
2403
+ function selectGoTarget({
2404
+ workPath,
2405
+ config,
2406
+ buildEnv
2407
+ }) {
2408
+ const entrypoint = readString(config?.buildpackEntrypoint);
2409
+ if (entrypoint)
2410
+ return packageDirectory(entrypoint);
2411
+ if (buildEnv && GO_TARGET_ENV in buildEnv)
2412
+ return void 0;
2413
+ const candidate = GO_CANDIDATE_ENTRYPOINTS.find(
2414
+ (name) => (0, import_node_fs9.existsSync)((0, import_node_path9.join)(workPath, name))
2415
+ );
2416
+ return candidate ? packageDirectory(candidate) : void 0;
2417
+ }
2418
+ var go = {
2419
+ runtime: "go",
2420
+ projectMarkers: ["go.mod"],
2421
+ buildpacks: [vercelBuildpack("go")],
2422
+ async resolveImage(workPath) {
2423
+ const version2 = selectGoVersion(workPath);
2424
+ return {
2425
+ version: version2,
2426
+ buildImage: `${GO_IMAGE_REPOSITORY}:${version2}-${GO_BUILD_IMAGE_DISTRO}`,
2427
+ runImage: GO_RUN_IMAGE
2428
+ };
2429
+ },
2430
+ platformEnv(params) {
2431
+ const target = selectGoTarget(params);
2432
+ return target ? { [GO_TARGET_ENV]: target } : {};
2433
+ }
2434
+ };
2435
+
2436
+ // src/buildpacks/ruby.ts
2437
+ var import_node_fs10 = require("fs");
2438
+ var import_node_path10 = require("path");
2339
2439
  var import_smol_toml2 = require("smol-toml");
2440
+
2441
+ // src/buildpacks/version.ts
2442
+ var VERSION_RE2 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/;
2443
+ function isValidVersion(version2) {
2444
+ return VERSION_RE2.test(version2) && version2.split(".").every((n) => Number.isSafeInteger(+n));
2445
+ }
2446
+
2447
+ // src/buildpacks/ruby.ts
2340
2448
  var DEFAULT_RUBY_VERSION = "3.4";
2341
2449
  var RUBY_IMAGE_REPOSITORY = "docker.io/library/ruby";
2342
2450
  var RUBY_VERSION_DOCS = "https://vercel.link/ruby-version";
@@ -2346,7 +2454,6 @@ var RUBY_VERSION_FILES = [
2346
2454
  "mise.toml"
2347
2455
  ];
2348
2456
  var VERSION_FILE_RE = /^ruby[\s-]*(?:=\s*)?["']?([^\s#"']+)["']?/m;
2349
- var VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/;
2350
2457
  var GEMFILE_RUBY_CALL_RE = /^\s*ruby\b(?!\s*:)/;
2351
2458
  var GEMFILE_RUBY_LINE_RE = /^\s*ruby(?:\s*\(\s*("[^"]*"|'[^']*')\s*\)|\s*("[^"]*"|'[^']*'))\s*(?:#.*)?$/;
2352
2459
  var GEMFILE_RAILS_GEM_RE = /^\s*gem\s+["']rails["']/m;
@@ -2360,10 +2467,10 @@ var ruby = {
2360
2467
  return { version: version2, buildImage: image, runImage: image };
2361
2468
  },
2362
2469
  validate({ workPath, buildEnv }) {
2363
- const gemfile = (0, import_node_path9.join)(workPath, "Gemfile");
2364
- if (!(0, import_node_fs9.existsSync)(gemfile))
2470
+ const gemfile = (0, import_node_path10.join)(workPath, "Gemfile");
2471
+ if (!(0, import_node_fs10.existsSync)(gemfile))
2365
2472
  return;
2366
- if (!GEMFILE_RAILS_GEM_RE.test((0, import_node_fs9.readFileSync)(gemfile, "utf8")))
2473
+ if (!GEMFILE_RAILS_GEM_RE.test((0, import_node_fs10.readFileSync)(gemfile, "utf8")))
2367
2474
  return;
2368
2475
  if (buildEnv?.SECRET_KEY_BASE)
2369
2476
  return;
@@ -2372,18 +2479,15 @@ var ruby = {
2372
2479
  );
2373
2480
  }
2374
2481
  };
2375
- function isValidVersion(version2) {
2376
- return VERSION_RE.test(version2) && version2.split(".").every((n) => Number.isSafeInteger(+n));
2377
- }
2378
2482
  function selectRubyVersion(workPath) {
2379
2483
  for (const name of RUBY_VERSION_FILES) {
2380
- const file = (0, import_node_path9.join)(workPath, name);
2381
- if ((0, import_node_fs9.existsSync)(file)) {
2382
- return parseVersionFile(name, (0, import_node_fs9.readFileSync)(file, "utf8"));
2484
+ const file = (0, import_node_path10.join)(workPath, name);
2485
+ if ((0, import_node_fs10.existsSync)(file)) {
2486
+ return parseVersionFile(name, (0, import_node_fs10.readFileSync)(file, "utf8"));
2383
2487
  }
2384
2488
  }
2385
- const gemfile = (0, import_node_path9.join)(workPath, "Gemfile");
2386
- return (0, import_node_fs9.existsSync)(gemfile) ? parseGemfileRubyVersion((0, import_node_fs9.readFileSync)(gemfile, "utf8")) : void 0;
2489
+ const gemfile = (0, import_node_path10.join)(workPath, "Gemfile");
2490
+ return (0, import_node_fs10.existsSync)(gemfile) ? parseGemfileRubyVersion((0, import_node_fs10.readFileSync)(gemfile, "utf8")) : void 0;
2387
2491
  }
2388
2492
  function parseVersionFile(name, contents) {
2389
2493
  let version2;
@@ -2419,8 +2523,69 @@ function parseGemfileRubyVersion(contents) {
2419
2523
  return [...version2.split("."), "0"].slice(0, 3).join(".");
2420
2524
  }
2421
2525
 
2526
+ // src/buildpacks/rust.ts
2527
+ var import_node_fs11 = require("fs");
2528
+ var import_node_path11 = require("path");
2529
+ var import_smol_toml3 = require("smol-toml");
2530
+ var DEFAULT_RUST_VERSION = "1";
2531
+ var RUST_IMAGE_REPOSITORY = "docker.io/library/rust";
2532
+ var RUST_BUILD_IMAGE_DISTRO = "bookworm";
2533
+ var RUST_RUN_IMAGE = "gcr.io/distroless/cc-debian12";
2534
+ var RUST_TOOLCHAIN_FILES = ["rust-toolchain", "rust-toolchain.toml"];
2535
+ var rust = {
2536
+ runtime: "rust",
2537
+ projectMarkers: ["Cargo.toml"],
2538
+ buildpacks: [vercelBuildpack("rust")],
2539
+ async resolveImage(workPath) {
2540
+ const version2 = selectRustVersion(workPath) ?? DEFAULT_RUST_VERSION;
2541
+ return {
2542
+ version: version2,
2543
+ buildImage: `${RUST_IMAGE_REPOSITORY}:${version2}-${RUST_BUILD_IMAGE_DISTRO}`,
2544
+ runImage: RUST_RUN_IMAGE
2545
+ };
2546
+ }
2547
+ };
2548
+ function selectRustVersion(workPath) {
2549
+ for (const name of RUST_TOOLCHAIN_FILES) {
2550
+ const file = (0, import_node_path11.join)(workPath, name);
2551
+ if ((0, import_node_fs11.existsSync)(file)) {
2552
+ const channel = parseToolchainFile(name, (0, import_node_fs11.readFileSync)(file, "utf8"));
2553
+ return channel !== void 0 && isValidVersion(channel) ? channel : void 0;
2554
+ }
2555
+ }
2556
+ return void 0;
2557
+ }
2558
+ function parseToolchainFile(name, contents) {
2559
+ const legacy = name === "rust-toolchain";
2560
+ let document;
2561
+ try {
2562
+ document = (0, import_smol_toml3.parse)(contents);
2563
+ } catch (error) {
2564
+ if (!legacy) {
2565
+ throw new Error(`Invalid ${name}: ${error.message}`);
2566
+ }
2567
+ }
2568
+ if (document === void 0 || !("toolchain" in document)) {
2569
+ return legacy ? contents.trim() || void 0 : void 0;
2570
+ }
2571
+ const { toolchain } = document;
2572
+ if (typeof toolchain !== "object" || toolchain === null) {
2573
+ throw new Error(`Invalid ${name}: [toolchain] must be a table.`);
2574
+ }
2575
+ const { channel } = toolchain;
2576
+ if (channel === void 0) {
2577
+ return void 0;
2578
+ }
2579
+ if (typeof channel !== "string" || channel.trim() === "") {
2580
+ throw new Error(
2581
+ `Invalid ${name}: toolchain.channel must be a string such as "1.90.0" or "stable".`
2582
+ );
2583
+ }
2584
+ return channel.trim();
2585
+ }
2586
+
2422
2587
  // src/buildpacks/registry.ts
2423
- var BUILDPACKS = [ruby];
2588
+ var BUILDPACKS = [ruby, go, rust];
2424
2589
  function requestedBuildpack(config) {
2425
2590
  if (!config)
2426
2591
  return void 0;
@@ -2428,13 +2593,13 @@ function requestedBuildpack(config) {
2428
2593
  }
2429
2594
  function hasProjectMarkers(buildpack, workPath) {
2430
2595
  return buildpack.projectMarkers.some(
2431
- (name) => (0, import_node_fs10.existsSync)((0, import_node_path10.join)(workPath, name))
2596
+ (name) => (0, import_node_fs12.existsSync)((0, import_node_path12.join)(workPath, name))
2432
2597
  );
2433
2598
  }
2434
2599
 
2435
2600
  // src/buildpacks/build.ts
2436
2601
  async function buildAndPushBuildpack(params) {
2437
- const sourceDir = (0, import_node_fs11.mkdtempSync)((0, import_node_path11.join)((0, import_node_os7.tmpdir)(), "vercel-cnb-source-"));
2602
+ const sourceDir = (0, import_node_fs13.mkdtempSync)((0, import_node_path13.join)((0, import_node_os7.tmpdir)(), "vercel-cnb-source-"));
2438
2603
  try {
2439
2604
  step("Staging buildpack source files");
2440
2605
  await stageWorkspace(params, sourceDir);
@@ -2448,9 +2613,24 @@ async function buildAndPushBuildpack(params) {
2448
2613
  workPath: sourceDir,
2449
2614
  buildEnv: params.buildEnv
2450
2615
  });
2616
+ const buildCommand = readString(params.config.buildCommand);
2617
+ if (buildCommand?.trim()) {
2618
+ warn(
2619
+ `The build command ${JSON.stringify(buildCommand)} is not supported and will be ignored.`
2620
+ );
2621
+ }
2451
2622
  const prereleaseUrl = getPrereleaseUrl();
2452
2623
  const buildpack = prereleaseUrl ? await withPrereleaseBuildpack(params.buildpack, prereleaseUrl) : params.buildpack;
2453
2624
  const image = await buildpack.resolveImage(sourceDir);
2625
+ const derivedEnv = buildpack.platformEnv?.({
2626
+ workPath: sourceDir,
2627
+ config: params.config,
2628
+ buildEnv: params.buildEnv
2629
+ }) ?? {};
2630
+ for (const [key, value] of Object.entries(derivedEnv)) {
2631
+ debug(`Passing ${key}=${value} to the ${buildpack.runtime} buildpack`);
2632
+ }
2633
+ const buildEnv = { ...params.buildEnv, ...derivedEnv };
2454
2634
  const nodeToolchain = engine.name === "buildah" ? await resolveNodeToolchain(sourceDir, params.config, params.meta) : await resolveLocalNodeToolchain(
2455
2635
  sourceDir,
2456
2636
  params.config,
@@ -2533,7 +2713,7 @@ async function buildAndPushBuildpack(params) {
2533
2713
  image,
2534
2714
  imageRef: target.imageRef,
2535
2715
  credentials,
2536
- buildEnv: params.buildEnv,
2716
+ buildEnv,
2537
2717
  nodeToolchain,
2538
2718
  cache
2539
2719
  },
@@ -2551,7 +2731,7 @@ async function buildAndPushBuildpack(params) {
2551
2731
  );
2552
2732
  } finally {
2553
2733
  try {
2554
- (0, import_node_fs11.rmSync)(sourceDir, { recursive: true, force: true });
2734
+ (0, import_node_fs13.rmSync)(sourceDir, { recursive: true, force: true });
2555
2735
  } catch {
2556
2736
  debug(`Could not remove buildpack source snapshot ${sourceDir}.`);
2557
2737
  }
@@ -2559,8 +2739,8 @@ async function buildAndPushBuildpack(params) {
2559
2739
  }
2560
2740
 
2561
2741
  // src/image-source.ts
2562
- var import_node_fs12 = require("fs");
2563
- var import_node_path12 = __toESM(require("path"));
2742
+ var import_node_fs14 = require("fs");
2743
+ var import_node_path14 = __toESM(require("path"));
2564
2744
  var DETECT_SENTINEL = "<detect>";
2565
2745
  function resolveImageSource(options, context) {
2566
2746
  const { config, workPath, entrypoint } = options;
@@ -2574,8 +2754,8 @@ function resolveImageSource(options, context) {
2574
2754
  }
2575
2755
  const dockerfileConfigured = entrypointRef && isDockerfileRef(entrypointRef) ? entrypointRef : findDockerfile(workPath);
2576
2756
  const dockerfileRel = dockerfileConfigured ?? "Dockerfile";
2577
- const dockerfilePath = import_node_path12.default.join(workPath, dockerfileRel);
2578
- const hasDockerfile = dockerfileConfigured !== void 0 || !buildpack && (0, import_node_fs12.existsSync)(dockerfilePath);
2757
+ const dockerfilePath = import_node_path14.default.join(workPath, dockerfileRel);
2758
+ const hasDockerfile = dockerfileConfigured !== void 0 || !buildpack && (0, import_node_fs14.existsSync)(dockerfilePath);
2579
2759
  if (hasDockerfile) {
2580
2760
  return { kind: "dockerfile", dockerfileRel, dockerfilePath };
2581
2761
  }
@@ -2593,9 +2773,9 @@ function resolveImageSource(options, context) {
2593
2773
 
2594
2774
  // src/dev.ts
2595
2775
  var import_node_child_process3 = require("child_process");
2596
- var import_node_fs13 = require("fs");
2776
+ var import_node_fs15 = require("fs");
2597
2777
  var import_node_os8 = require("os");
2598
- var import_node_path13 = __toESM(require("path"));
2778
+ var import_node_path15 = __toESM(require("path"));
2599
2779
  var HOST_ONLY_ENV = /* @__PURE__ */ new Set([
2600
2780
  "TMPDIR",
2601
2781
  "TMP",
@@ -2625,8 +2805,8 @@ function isHostOnlyEnvVar(key) {
2625
2805
  return HOST_ONLY_ENV.has(key) || key.startsWith("__") || key.startsWith("XPC_") || key.startsWith("SSH_") || key.startsWith("Apple");
2626
2806
  }
2627
2807
  function writeEnvFile(env) {
2628
- const dir = (0, import_node_fs13.mkdtempSync)(import_node_path13.default.join((0, import_node_os8.tmpdir)(), "vercel-container-dev-env-"));
2629
- const file = import_node_path13.default.join(dir, "env");
2808
+ const dir = (0, import_node_fs15.mkdtempSync)(import_node_path15.default.join((0, import_node_os8.tmpdir)(), "vercel-container-dev-env-"));
2809
+ const file = import_node_path15.default.join(dir, "env");
2630
2810
  const lines = [];
2631
2811
  for (const [key, value] of Object.entries(env)) {
2632
2812
  if (value.includes("\n")) {
@@ -2634,7 +2814,7 @@ function writeEnvFile(env) {
2634
2814
  }
2635
2815
  lines.push(`${key}=${value}`);
2636
2816
  }
2637
- (0, import_node_fs13.writeFileSync)(file, `${lines.join("\n")}
2817
+ (0, import_node_fs15.writeFileSync)(file, `${lines.join("\n")}
2638
2818
  `);
2639
2819
  return file;
2640
2820
  }
@@ -2725,14 +2905,14 @@ async function resolveDevImage(options, out, span) {
2725
2905
  );
2726
2906
  }
2727
2907
  const { dockerfilePath } = source;
2728
- if (!(0, import_node_fs13.existsSync)(dockerfilePath)) {
2908
+ if (!(0, import_node_fs15.existsSync)(dockerfilePath)) {
2729
2909
  throw new Error(
2730
2910
  `Dockerfile not found at "${dockerfilePath}" for container service.`
2731
2911
  );
2732
2912
  }
2733
2913
  const serviceName = options.service?.name ?? "service";
2734
2914
  const tag = devImageTag(serviceName);
2735
- const contextDir = import_node_path13.default.dirname(dockerfilePath);
2915
+ const contextDir = import_node_path15.default.dirname(dockerfilePath);
2736
2916
  const buildArgFlags2 = [];
2737
2917
  const buildEnv = options.meta?.buildEnv ?? {};
2738
2918
  for (const [key, value] of Object.entries(buildEnv)) {
@@ -2937,7 +3117,7 @@ async function startContainer(options, reuseKey) {
2937
3117
  }
2938
3118
  });
2939
3119
  const cleanupEnvFile = () => {
2940
- (0, import_node_fs13.rmSync)(import_node_path13.default.dirname(envFilePath), { recursive: true, force: true });
3120
+ (0, import_node_fs15.rmSync)(import_node_path15.default.dirname(envFilePath), { recursive: true, force: true });
2941
3121
  };
2942
3122
  const shutdown = async () => {
2943
3123
  runningContainers.delete(reuseKey);
@@ -3014,12 +3194,12 @@ async function startContainer(options, reuseKey) {
3014
3194
 
3015
3195
  // src/prepare-cache.ts
3016
3196
  var import_build_utils5 = require("@vercel/build-utils");
3017
- var import_node_fs14 = require("fs");
3018
- var import_node_path14 = require("path");
3197
+ var import_node_fs16 = require("fs");
3198
+ var import_node_path16 = require("path");
3019
3199
  async function prepareCache(options) {
3020
- const root = (0, import_node_path14.resolve)(options.repoRootPath || options.workPath);
3200
+ const root = (0, import_node_path16.resolve)(options.repoRootPath || options.workPath);
3021
3201
  if (!buildpackCacheEnabled()) {
3022
- (0, import_node_fs14.rmSync)((0, import_node_path14.join)(root, BUILDPACK_CACHE_DIR), { recursive: true, force: true });
3202
+ (0, import_node_fs16.rmSync)((0, import_node_path16.join)(root, BUILDPACK_CACHE_DIR), { recursive: true, force: true });
3023
3203
  return {};
3024
3204
  }
3025
3205
  const start = Date.now();
@@ -3244,22 +3424,22 @@ async function resolveImageHandler(options, source, span) {
3244
3424
  if (meta?.isDev) {
3245
3425
  const serviceName2 = options.service?.name;
3246
3426
  const tag2 = devImageTag(
3247
- serviceName2 ?? import_node_path15.default.basename(dockerfileRel).split(".")[0]
3427
+ serviceName2 ?? import_node_path17.default.basename(dockerfileRel).split(".")[0]
3248
3428
  );
3249
3429
  span?.setAttributes({ "container.mode": "dev", "image.tag": tag2 });
3250
3430
  return tag2;
3251
3431
  }
3252
- if (!(0, import_node_fs15.existsSync)(dockerfilePath)) {
3432
+ if (!(0, import_node_fs17.existsSync)(dockerfilePath)) {
3253
3433
  throw new Error(
3254
3434
  `Dockerfile not found at "${dockerfilePath}" for container service.`
3255
3435
  );
3256
3436
  }
3257
3437
  const serviceName = options.service?.name;
3258
3438
  const repository = sanitizeRepository(
3259
- serviceName ?? import_node_path15.default.basename(dockerfileRel).split(".")[0]
3439
+ serviceName ?? import_node_path17.default.basename(dockerfileRel).split(".")[0]
3260
3440
  );
3261
3441
  const tag = resolveImageTag();
3262
- const contextDir = import_node_path15.default.dirname(dockerfilePath);
3442
+ const contextDir = import_node_path17.default.dirname(dockerfilePath);
3263
3443
  const buildArgs = buildArgsFromEnv(meta?.buildEnv);
3264
3444
  span?.setAttributes({
3265
3445
  "container.mode": "build_and_push",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/container",
3
- "version": "12.0.0",
3
+ "version": "14.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://vercel.com/docs",
@@ -17,12 +17,12 @@
17
17
  "tar": "7.5.11"
18
18
  },
19
19
  "peerDependencies": {
20
- "@vercel/build-utils": "14.14.0"
20
+ "@vercel/build-utils": "14.16.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "20.11.0",
24
24
  "vitest": "4.1.10",
25
- "@vercel/build-utils": "14.14.0"
25
+ "@vercel/build-utils": "14.16.0"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
@@ -31,7 +31,7 @@
31
31
  "build": "node ../../utils/build-builder.mjs",
32
32
  "type-check": "tsc --noEmit",
33
33
  "test": "vitest run --config ../../vitest.config.mts",
34
- "test-unit": "vitest run --config ../../vitest.config.mts test/unit.test.ts test/diagnostics.test.ts test/workspace.test.ts test/lifecycle-docker.test.ts test/ruby-version.test.ts test/docker-push.test.ts test/cache.test.ts",
34
+ "test-unit": "vitest run --config ../../vitest.config.mts test/unit.test.ts test/diagnostics.test.ts test/workspace.test.ts test/lifecycle-docker.test.ts test/ruby-version.test.ts test/go-version.test.ts test/rust-version.test.ts test/docker-push.test.ts test/cache.test.ts",
35
35
  "test-e2e": "vitest run --config ../../vitest.config.mts test/e2e.test.ts"
36
36
  }
37
37
  }