@vercel/container 24.0.0-snapshot-c4f338842961 → 24.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/index.js +256 -114
- package/dist/schedules-command-dispatcher +0 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -99,8 +99,8 @@ async function generateProjectManifest({
|
|
|
99
99
|
var diagnostics = (0, import_build_utils.createDiagnostics)("container");
|
|
100
100
|
|
|
101
101
|
// src/index.ts
|
|
102
|
-
var
|
|
103
|
-
var
|
|
102
|
+
var import_node_fs17 = require("fs");
|
|
103
|
+
var import_node_path23 = __toESM(require("path"));
|
|
104
104
|
|
|
105
105
|
// src/util.ts
|
|
106
106
|
var import_build_utils2 = require("@vercel/build-utils");
|
|
@@ -771,7 +771,7 @@ function pullFlags(params) {
|
|
|
771
771
|
if (params.baseImageIsLocal) {
|
|
772
772
|
return ["--pull=never"];
|
|
773
773
|
}
|
|
774
|
-
return params.useBuildahStoreCache ? ["--pull=
|
|
774
|
+
return params.useBuildahStoreCache ? ["--pull=newer"] : [];
|
|
775
775
|
}
|
|
776
776
|
async function deploymentSourceDateEpoch() {
|
|
777
777
|
if ((0, import_build_utils3.resolveBuildConcurrency)() <= 1) {
|
|
@@ -1460,9 +1460,9 @@ Continuing (set VERCEL_VCR_STRICT_STORAGE=1 to fail builds).`
|
|
|
1460
1460
|
};
|
|
1461
1461
|
|
|
1462
1462
|
// src/buildpacks/build.ts
|
|
1463
|
-
var
|
|
1463
|
+
var import_node_fs14 = require("fs");
|
|
1464
1464
|
var import_node_os10 = require("os");
|
|
1465
|
-
var
|
|
1465
|
+
var import_node_path18 = require("path");
|
|
1466
1466
|
|
|
1467
1467
|
// src/buildpacks/cache.ts
|
|
1468
1468
|
var import_node_crypto4 = require("crypto");
|
|
@@ -1765,6 +1765,12 @@ var BUILD_USER_ID = 1001;
|
|
|
1765
1765
|
var BUILD_GROUP_ID = 1001;
|
|
1766
1766
|
var BUILD_USER = `${BUILD_USER_ID}:${BUILD_GROUP_ID}`;
|
|
1767
1767
|
var CNB_PLATFORM_API = "0.15";
|
|
1768
|
+
var CREATOR_KEYCHAIN_ENV_ARGS = [
|
|
1769
|
+
"--env",
|
|
1770
|
+
"CNB_REGISTRY_AUTH_KEYCHAIN_SKIP_AMAZON=true",
|
|
1771
|
+
"--env",
|
|
1772
|
+
"CNB_REGISTRY_AUTH_KEYCHAIN_SKIP_AZURE=true"
|
|
1773
|
+
];
|
|
1768
1774
|
var ORDER_MOUNT_DIR = "/platform/order";
|
|
1769
1775
|
var ORDER_FILE = `${ORDER_MOUNT_DIR}/order.toml`;
|
|
1770
1776
|
var CACHE_MOUNT_DIR = "/cache";
|
|
@@ -2103,10 +2109,10 @@ function creatorArgs(image, imageRef, options = {}) {
|
|
|
2103
2109
|
}
|
|
2104
2110
|
|
|
2105
2111
|
// src/buildpacks/lifecycle/buildah.ts
|
|
2106
|
-
var
|
|
2112
|
+
var import_node_fs7 = require("fs");
|
|
2107
2113
|
var import_node_crypto6 = require("crypto");
|
|
2108
2114
|
var import_node_os8 = require("os");
|
|
2109
|
-
var
|
|
2115
|
+
var import_node_path11 = require("path");
|
|
2110
2116
|
|
|
2111
2117
|
// src/buildah-store-cache/cleanup.ts
|
|
2112
2118
|
var import_node_child_process3 = require("child_process");
|
|
@@ -2199,6 +2205,133 @@ async function recordPendingCleanup(container) {
|
|
|
2199
2205
|
}
|
|
2200
2206
|
}
|
|
2201
2207
|
|
|
2208
|
+
// src/buildpacks/lifecycle/build-user.ts
|
|
2209
|
+
var import_node_fs6 = require("fs");
|
|
2210
|
+
var import_node_path10 = require("path");
|
|
2211
|
+
var BUILD_USER_NAME = "cnb";
|
|
2212
|
+
var BUILD_USER_DIRECTORIES = ["layers", "platform", "workspace", "home/cnb"];
|
|
2213
|
+
var BUILD_GROUP_ENTRY = {
|
|
2214
|
+
kind: "group",
|
|
2215
|
+
file: "etc/group",
|
|
2216
|
+
fields: [BUILD_USER_NAME, "x", String(BUILD_GROUP_ID), ""],
|
|
2217
|
+
identity: [0, 2]
|
|
2218
|
+
};
|
|
2219
|
+
var BUILD_USER_ENTRY = {
|
|
2220
|
+
kind: "user",
|
|
2221
|
+
file: "etc/passwd",
|
|
2222
|
+
fields: [
|
|
2223
|
+
BUILD_USER_NAME,
|
|
2224
|
+
"x",
|
|
2225
|
+
String(BUILD_USER_ID),
|
|
2226
|
+
String(BUILD_GROUP_ID),
|
|
2227
|
+
"",
|
|
2228
|
+
`/home/${BUILD_USER_NAME}`,
|
|
2229
|
+
"/bin/sh"
|
|
2230
|
+
],
|
|
2231
|
+
identity: [0, 2, 3]
|
|
2232
|
+
};
|
|
2233
|
+
var MountedRootfs = class {
|
|
2234
|
+
constructor(root) {
|
|
2235
|
+
this.root = root;
|
|
2236
|
+
if (!(0, import_node_path10.isAbsolute)(root)) {
|
|
2237
|
+
throw new Error(`Expected the build image's mount point, got "${root}".`);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
ensureDirectory(relativePath) {
|
|
2241
|
+
return this.directory(relativePath, true);
|
|
2242
|
+
}
|
|
2243
|
+
readFile(relativePath) {
|
|
2244
|
+
const fd = this.openFile(relativePath, import_node_fs6.constants.O_RDONLY);
|
|
2245
|
+
try {
|
|
2246
|
+
return (0, import_node_fs6.readFileSync)(fd, "utf8");
|
|
2247
|
+
} finally {
|
|
2248
|
+
(0, import_node_fs6.closeSync)(fd);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
appendFile(relativePath, text) {
|
|
2252
|
+
const fd = this.openFile(
|
|
2253
|
+
relativePath,
|
|
2254
|
+
import_node_fs6.constants.O_WRONLY | import_node_fs6.constants.O_APPEND
|
|
2255
|
+
);
|
|
2256
|
+
try {
|
|
2257
|
+
(0, import_node_fs6.writeSync)(fd, text);
|
|
2258
|
+
} finally {
|
|
2259
|
+
(0, import_node_fs6.closeSync)(fd);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
directory(relativePath, create) {
|
|
2263
|
+
let path4 = this.root;
|
|
2264
|
+
for (const component of relativePath.split("/")) {
|
|
2265
|
+
path4 = (0, import_node_path10.join)(path4, component);
|
|
2266
|
+
const stat = lstatIfPresent2(path4);
|
|
2267
|
+
if (!stat && create) {
|
|
2268
|
+
(0, import_node_fs6.mkdirSync)(path4, { mode: 493 });
|
|
2269
|
+
} else if (!stat?.isDirectory()) {
|
|
2270
|
+
throw new Error(
|
|
2271
|
+
`/${relativePath} in the build image is missing or not a directory.`
|
|
2272
|
+
);
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
return path4;
|
|
2276
|
+
}
|
|
2277
|
+
openFile(relativePath, flags) {
|
|
2278
|
+
const separator = relativePath.lastIndexOf("/");
|
|
2279
|
+
const parent = this.directory(relativePath.slice(0, separator), false);
|
|
2280
|
+
const fd = (0, import_node_fs6.openSync)(
|
|
2281
|
+
(0, import_node_path10.join)(parent, relativePath.slice(separator + 1)),
|
|
2282
|
+
flags | import_node_fs6.constants.O_NOFOLLOW
|
|
2283
|
+
);
|
|
2284
|
+
if (!(0, import_node_fs6.fstatSync)(fd).isFile()) {
|
|
2285
|
+
(0, import_node_fs6.closeSync)(fd);
|
|
2286
|
+
throw new Error(`/${relativePath} in the build image is not a file.`);
|
|
2287
|
+
}
|
|
2288
|
+
return fd;
|
|
2289
|
+
}
|
|
2290
|
+
};
|
|
2291
|
+
function lstatIfPresent2(path4) {
|
|
2292
|
+
try {
|
|
2293
|
+
return (0, import_node_fs6.lstatSync)(path4);
|
|
2294
|
+
} catch (error) {
|
|
2295
|
+
if (error.code === "ENOENT")
|
|
2296
|
+
return void 0;
|
|
2297
|
+
throw error;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
function addAccount(rootfs, entry) {
|
|
2301
|
+
const contents = rootfs.readFile(entry.file);
|
|
2302
|
+
const [name, , id] = entry.fields;
|
|
2303
|
+
const matches = contents.split("\n").filter((line) => {
|
|
2304
|
+
const [lineName, , lineId] = line.split(":");
|
|
2305
|
+
return lineName === name || lineId === id;
|
|
2306
|
+
});
|
|
2307
|
+
const conflict = matches.find((line) => {
|
|
2308
|
+
const fields = line.split(":");
|
|
2309
|
+
return entry.identity.some((i) => fields[i] !== entry.fields[i]);
|
|
2310
|
+
});
|
|
2311
|
+
if (conflict !== void 0) {
|
|
2312
|
+
throw new Error(
|
|
2313
|
+
`Cannot add the ${name} build ${entry.kind} to the build image: /${entry.file} already has "${conflict}".`
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2316
|
+
if (matches.length > 0)
|
|
2317
|
+
return;
|
|
2318
|
+
const separator = contents === "" || contents.endsWith("\n") ? "" : "\n";
|
|
2319
|
+
rootfs.appendFile(entry.file, `${separator}${entry.fields.join(":")}
|
|
2320
|
+
`);
|
|
2321
|
+
}
|
|
2322
|
+
function addBuildUser(mountPoint) {
|
|
2323
|
+
const rootfs = new MountedRootfs(mountPoint);
|
|
2324
|
+
addAccount(rootfs, BUILD_GROUP_ENTRY);
|
|
2325
|
+
addAccount(rootfs, BUILD_USER_ENTRY);
|
|
2326
|
+
for (const directory of BUILD_USER_DIRECTORIES) {
|
|
2327
|
+
(0, import_node_fs6.lchownSync)(
|
|
2328
|
+
rootfs.ensureDirectory(directory),
|
|
2329
|
+
BUILD_USER_ID,
|
|
2330
|
+
BUILD_GROUP_ID
|
|
2331
|
+
);
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2202
2335
|
// src/buildpacks/lifecycle/buildah.ts
|
|
2203
2336
|
async function cleanUpBuildContainer(name) {
|
|
2204
2337
|
try {
|
|
@@ -2227,7 +2360,7 @@ function cacheScratchParent() {
|
|
|
2227
2360
|
if (isBuildContainer()) {
|
|
2228
2361
|
const dir = "/vercel/.cnb";
|
|
2229
2362
|
try {
|
|
2230
|
-
(0,
|
|
2363
|
+
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
2231
2364
|
return dir;
|
|
2232
2365
|
} catch (error) {
|
|
2233
2366
|
debug(
|
|
@@ -2238,16 +2371,16 @@ function cacheScratchParent() {
|
|
|
2238
2371
|
return (0, import_node_os8.tmpdir)();
|
|
2239
2372
|
}
|
|
2240
2373
|
function chownTree(root, uid, gid) {
|
|
2241
|
-
const stat = (0,
|
|
2374
|
+
const stat = (0, import_node_fs7.lstatSync)(root);
|
|
2242
2375
|
if (stat.isDirectory()) {
|
|
2243
|
-
(0,
|
|
2244
|
-
for (const entry of (0,
|
|
2245
|
-
chownTree((0,
|
|
2376
|
+
(0, import_node_fs7.chmodSync)(root, 493);
|
|
2377
|
+
for (const entry of (0, import_node_fs7.readdirSync)(root)) {
|
|
2378
|
+
chownTree((0, import_node_path11.join)(root, entry), uid, gid);
|
|
2246
2379
|
}
|
|
2247
2380
|
} else if (stat.isFile()) {
|
|
2248
|
-
(0,
|
|
2381
|
+
(0, import_node_fs7.chmodSync)(root, 420);
|
|
2249
2382
|
}
|
|
2250
|
-
(0,
|
|
2383
|
+
(0, import_node_fs7.lchownSync)(root, uid, gid);
|
|
2251
2384
|
}
|
|
2252
2385
|
var RegistrySetupFailure = class extends Error {
|
|
2253
2386
|
constructor(reason) {
|
|
@@ -2255,6 +2388,22 @@ var RegistrySetupFailure = class extends Error {
|
|
|
2255
2388
|
this.reason = reason;
|
|
2256
2389
|
}
|
|
2257
2390
|
};
|
|
2391
|
+
async function addBuildUserThroughMount(buildContainer, client) {
|
|
2392
|
+
const { stdout } = await client.run(["mount", buildContainer], {
|
|
2393
|
+
quiet: true
|
|
2394
|
+
});
|
|
2395
|
+
try {
|
|
2396
|
+
addBuildUser(stdout.trim());
|
|
2397
|
+
} finally {
|
|
2398
|
+
try {
|
|
2399
|
+
await client.run(["umount", buildContainer], { quiet: true });
|
|
2400
|
+
} catch (error) {
|
|
2401
|
+
debug(
|
|
2402
|
+
`could not unmount Buildah CNB container ${buildContainer}: ${error.message}`
|
|
2403
|
+
);
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2258
2407
|
async function prepareBuildContainer(buildContainer, buildpack, params, client) {
|
|
2259
2408
|
const start = Date.now();
|
|
2260
2409
|
step(
|
|
@@ -2273,16 +2422,7 @@ async function prepareBuildContainer(buildContainer, buildpack, params, client)
|
|
|
2273
2422
|
await usage?.record(async () => [
|
|
2274
2423
|
await inspectBaseImageId(buildContainer, client)
|
|
2275
2424
|
]);
|
|
2276
|
-
await client
|
|
2277
|
-
"run",
|
|
2278
|
-
"--network",
|
|
2279
|
-
"host",
|
|
2280
|
-
buildContainer,
|
|
2281
|
-
"--",
|
|
2282
|
-
"sh",
|
|
2283
|
-
"-c",
|
|
2284
|
-
`groupadd -g ${BUILD_GROUP_ID} cnb && useradd -m -u ${BUILD_USER_ID} -g ${BUILD_GROUP_ID} cnb && mkdir -p /layers /platform /workspace && chown -R ${BUILD_USER} /layers /platform /workspace /home/cnb`
|
|
2285
|
-
]);
|
|
2425
|
+
await addBuildUserThroughMount(buildContainer, client);
|
|
2286
2426
|
await client.run([
|
|
2287
2427
|
"copy",
|
|
2288
2428
|
"--chown",
|
|
@@ -2304,10 +2444,10 @@ async function copySavedCache(dir, buildContainer, containerReady, client) {
|
|
|
2304
2444
|
step("Restoring the buildpack cache");
|
|
2305
2445
|
let scratch;
|
|
2306
2446
|
try {
|
|
2307
|
-
scratch = (0,
|
|
2308
|
-
(0,
|
|
2309
|
-
const cacheDir = (0,
|
|
2310
|
-
(0,
|
|
2447
|
+
scratch = (0, import_node_fs7.mkdtempSync)((0, import_node_path11.join)(cacheScratchParent(), "vercel-cnb-cache-"));
|
|
2448
|
+
(0, import_node_fs7.chmodSync)(scratch, 493);
|
|
2449
|
+
const cacheDir = (0, import_node_path11.join)(scratch, "cache");
|
|
2450
|
+
(0, import_node_fs7.mkdirSync)(cacheDir, { mode: 493 });
|
|
2311
2451
|
const imageId = containerReady.then(
|
|
2312
2452
|
() => inspectBaseImageId(buildContainer, client)
|
|
2313
2453
|
);
|
|
@@ -2360,12 +2500,12 @@ async function buildAndPushWithLifecycle(buildpack, params, client, span) {
|
|
|
2360
2500
|
let cacheScratch;
|
|
2361
2501
|
let containerCleanup;
|
|
2362
2502
|
try {
|
|
2363
|
-
reportDir = (0,
|
|
2364
|
-
const reportPath = (0,
|
|
2365
|
-
(0,
|
|
2366
|
-
(0,
|
|
2367
|
-
cnbDir = (0,
|
|
2368
|
-
(0,
|
|
2503
|
+
reportDir = (0, import_node_fs7.mkdtempSync)((0, import_node_path11.join)((0, import_node_os8.tmpdir)(), "vercel-cnb-report-"));
|
|
2504
|
+
const reportPath = (0, import_node_path11.join)(reportDir, "report.toml");
|
|
2505
|
+
(0, import_node_fs7.chownSync)(reportDir, BUILD_USER_ID, BUILD_GROUP_ID);
|
|
2506
|
+
(0, import_node_fs7.chmodSync)(reportDir, 493);
|
|
2507
|
+
cnbDir = (0, import_node_fs7.mkdtempSync)((0, import_node_path11.join)((0, import_node_os8.tmpdir)(), "vercel-cnb-"));
|
|
2508
|
+
(0, import_node_fs7.chmodSync)(cnbDir, 493);
|
|
2369
2509
|
orderDir = writeOrderDir(buildpack);
|
|
2370
2510
|
platformEnvDir = writePlatformEnvDir(params.buildEnv, {
|
|
2371
2511
|
nodeHome: params.nodeToolchain?.home,
|
|
@@ -2438,6 +2578,7 @@ async function buildAndPushWithLifecycle(buildpack, params, client, span) {
|
|
|
2438
2578
|
`CNB_PLATFORM_API=${CNB_PLATFORM_API}`,
|
|
2439
2579
|
"--env",
|
|
2440
2580
|
"CNB_REGISTRY_AUTH",
|
|
2581
|
+
...CREATOR_KEYCHAIN_ENV_ARGS,
|
|
2441
2582
|
"--volume",
|
|
2442
2583
|
`${cnbDir}:/cnb:ro`,
|
|
2443
2584
|
"--volume",
|
|
@@ -2459,7 +2600,7 @@ async function buildAndPushWithLifecycle(buildpack, params, client, span) {
|
|
|
2459
2600
|
{ env: lifecycleEnv }
|
|
2460
2601
|
);
|
|
2461
2602
|
containerCleanup = cleanUpBuildContainer(buildContainer);
|
|
2462
|
-
const digest = readReportDigest((0,
|
|
2603
|
+
const digest = readReportDigest((0, import_node_fs7.readFileSync)(reportPath, "utf8"));
|
|
2463
2604
|
if (!digest) {
|
|
2464
2605
|
throw new Error(
|
|
2465
2606
|
`${buildpack.runtime} buildpack lifecycle did not report a digest.`
|
|
@@ -2505,7 +2646,7 @@ async function buildAndPushWithLifecycle(buildpack, params, client, span) {
|
|
|
2505
2646
|
]) {
|
|
2506
2647
|
if (dir) {
|
|
2507
2648
|
try {
|
|
2508
|
-
(0,
|
|
2649
|
+
(0, import_node_fs7.rmSync)(dir, { recursive: true, force: true });
|
|
2509
2650
|
} catch {
|
|
2510
2651
|
debug(`Could not remove Buildah build scratch directory ${dir}.`);
|
|
2511
2652
|
}
|
|
@@ -2519,9 +2660,9 @@ async function buildAndPushWithLifecycle(buildpack, params, client, span) {
|
|
|
2519
2660
|
|
|
2520
2661
|
// src/buildpacks/lifecycle/docker.ts
|
|
2521
2662
|
var import_node_crypto7 = require("crypto");
|
|
2522
|
-
var
|
|
2663
|
+
var import_node_fs8 = require("fs");
|
|
2523
2664
|
var import_node_os9 = require("os");
|
|
2524
|
-
var
|
|
2665
|
+
var import_node_path12 = require("path");
|
|
2525
2666
|
function localBuildImageDockerfile(buildImage, nodeMajor) {
|
|
2526
2667
|
const lines = [];
|
|
2527
2668
|
if (nodeMajor !== void 0) {
|
|
@@ -2566,9 +2707,9 @@ var buildAndPushWithLifecycleDocker = async (buildpack, params, span) => {
|
|
|
2566
2707
|
let stageDir;
|
|
2567
2708
|
const containers = [];
|
|
2568
2709
|
try {
|
|
2569
|
-
stageDir = (0,
|
|
2570
|
-
const cnbDir = (0,
|
|
2571
|
-
(0,
|
|
2710
|
+
stageDir = (0, import_node_fs8.mkdtempSync)((0, import_node_path12.join)((0, import_node_os9.tmpdir)(), "vercel-cnb-"));
|
|
2711
|
+
const cnbDir = (0, import_node_path12.join)(stageDir, "cnb");
|
|
2712
|
+
(0, import_node_fs8.mkdirSync)(cnbDir, { mode: 493 });
|
|
2572
2713
|
const orderDir = writeOrderDir(buildpack, stageDir);
|
|
2573
2714
|
const platformEnvDir = writePlatformEnvDir(
|
|
2574
2715
|
params.buildEnv,
|
|
@@ -2587,7 +2728,7 @@ var buildAndPushWithLifecycleDocker = async (buildpack, params, span) => {
|
|
|
2587
2728
|
params.nodeToolchain?.major
|
|
2588
2729
|
);
|
|
2589
2730
|
const buildImageTag = localBuildImageTag(dockerfile);
|
|
2590
|
-
const buildImageIdPath = (0,
|
|
2731
|
+
const buildImageIdPath = (0, import_node_path12.join)(stageDir, "build-image.id");
|
|
2591
2732
|
step(
|
|
2592
2733
|
`Preparing ${buildpack.runtime} ${params.image.version} build image` + (params.nodeToolchain ? ` with Node.js ${params.nodeToolchain.major}` : "")
|
|
2593
2734
|
);
|
|
@@ -2605,7 +2746,7 @@ var buildAndPushWithLifecycleDocker = async (buildpack, params, span) => {
|
|
|
2605
2746
|
],
|
|
2606
2747
|
{ input: dockerfile }
|
|
2607
2748
|
);
|
|
2608
|
-
const buildImageId = (0,
|
|
2749
|
+
const buildImageId = (0, import_node_fs8.readFileSync)(buildImageIdPath, "utf8").trim();
|
|
2609
2750
|
if (!/^sha256:[a-f0-9]{64}$/.test(buildImageId)) {
|
|
2610
2751
|
throw new Error("Docker build did not report a valid image ID.");
|
|
2611
2752
|
}
|
|
@@ -2680,6 +2821,7 @@ var buildAndPushWithLifecycleDocker = async (buildpack, params, span) => {
|
|
|
2680
2821
|
`CNB_PLATFORM_API=${CNB_PLATFORM_API}`,
|
|
2681
2822
|
"--env",
|
|
2682
2823
|
"CNB_REGISTRY_AUTH",
|
|
2824
|
+
...CREATOR_KEYCHAIN_ENV_ARGS,
|
|
2683
2825
|
"--volumes-from",
|
|
2684
2826
|
initContainerName,
|
|
2685
2827
|
"--entrypoint",
|
|
@@ -2693,13 +2835,13 @@ var buildAndPushWithLifecycleDocker = async (buildpack, params, span) => {
|
|
|
2693
2835
|
`Building and publishing ${params.imageRef} via Vercel ${buildpack.runtime} buildpacks`
|
|
2694
2836
|
);
|
|
2695
2837
|
await runDocker2(["start", "--attach", containerName]);
|
|
2696
|
-
const reportPath = (0,
|
|
2838
|
+
const reportPath = (0, import_node_path12.join)(stageDir, "report.toml");
|
|
2697
2839
|
await runDocker2([
|
|
2698
2840
|
"cp",
|
|
2699
2841
|
`${containerName}:/platform-output/report.toml`,
|
|
2700
2842
|
reportPath
|
|
2701
2843
|
]);
|
|
2702
|
-
const digest = readReportDigest((0,
|
|
2844
|
+
const digest = readReportDigest((0, import_node_fs8.readFileSync)(reportPath, "utf8"));
|
|
2703
2845
|
if (!digest) {
|
|
2704
2846
|
throw new Error(
|
|
2705
2847
|
`${buildpack.runtime} buildpack lifecycle did not report a digest.`
|
|
@@ -2734,7 +2876,7 @@ var buildAndPushWithLifecycleDocker = async (buildpack, params, span) => {
|
|
|
2734
2876
|
}
|
|
2735
2877
|
if (stageDir) {
|
|
2736
2878
|
try {
|
|
2737
|
-
(0,
|
|
2879
|
+
(0, import_node_fs8.rmSync)(stageDir, { recursive: true, force: true });
|
|
2738
2880
|
} catch {
|
|
2739
2881
|
debug(
|
|
2740
2882
|
`Could not remove Docker build scratch directory ${stageDir}.`
|
|
@@ -2748,10 +2890,10 @@ var buildAndPushWithLifecycleDocker = async (buildpack, params, span) => {
|
|
|
2748
2890
|
|
|
2749
2891
|
// src/buildpacks/node-toolchain.ts
|
|
2750
2892
|
var import_build_utils5 = require("@vercel/build-utils");
|
|
2751
|
-
var
|
|
2752
|
-
var
|
|
2893
|
+
var import_node_fs9 = require("fs");
|
|
2894
|
+
var import_node_path13 = require("path");
|
|
2753
2895
|
async function selectNodeMajor(workPath, config, meta) {
|
|
2754
|
-
if (!(0,
|
|
2896
|
+
if (!(0, import_node_fs9.existsSync)((0, import_node_path13.join)(workPath, "package.json"))) {
|
|
2755
2897
|
return void 0;
|
|
2756
2898
|
}
|
|
2757
2899
|
const version2 = await (0, import_build_utils5.getNodeVersion)(workPath, void 0, config, meta);
|
|
@@ -2772,7 +2914,7 @@ async function resolveNodeToolchain(workPath, config, meta) {
|
|
|
2772
2914
|
return void 0;
|
|
2773
2915
|
}
|
|
2774
2916
|
for (const executable of ["node", "npm"]) {
|
|
2775
|
-
if (!(0,
|
|
2917
|
+
if (!(0, import_node_fs9.existsSync)((0, import_node_path13.join)(toolchain.home, "bin", executable))) {
|
|
2776
2918
|
throw new Error(
|
|
2777
2919
|
`The selected Node.js ${toolchain.version} installation is missing ${toolchain.home}/bin/${executable} in the build environment.`
|
|
2778
2920
|
);
|
|
@@ -2785,16 +2927,16 @@ async function resolveLocalNodeToolchain(workPath, config, meta) {
|
|
|
2785
2927
|
}
|
|
2786
2928
|
|
|
2787
2929
|
// src/buildpacks/registry.ts
|
|
2788
|
-
var
|
|
2789
|
-
var
|
|
2930
|
+
var import_node_fs13 = require("fs");
|
|
2931
|
+
var import_node_path17 = require("path");
|
|
2790
2932
|
|
|
2791
2933
|
// src/buildpacks/go.ts
|
|
2792
|
-
var
|
|
2793
|
-
var
|
|
2934
|
+
var import_node_fs10 = require("fs");
|
|
2935
|
+
var import_node_path14 = require("path");
|
|
2794
2936
|
var DEFAULT_GO_VERSION = "1";
|
|
2795
2937
|
var GO_IMAGE_REPOSITORY = "docker.io/library/golang";
|
|
2796
2938
|
var GO_BUILD_IMAGE_DISTRO = "bookworm";
|
|
2797
|
-
var GO_RUN_IMAGE = "gcr.io/distroless/cc-debian12";
|
|
2939
|
+
var GO_RUN_IMAGE = "gcr.io/distroless/cc-debian12@sha256:6dc8478fd8e790ae427aeff51e588573dec83b13adb7e5d10505a717927009b5";
|
|
2798
2940
|
var OLDEST_IMAGE_MINOR = 21;
|
|
2799
2941
|
var GO_CANDIDATE_ENTRYPOINTS = [
|
|
2800
2942
|
"main.go",
|
|
@@ -2819,10 +2961,10 @@ function compareImageVersions(a, b) {
|
|
|
2819
2961
|
return a.parts[0] - b.parts[0] || a.parts[1] - b.parts[1] || a.parts[2] - b.parts[2];
|
|
2820
2962
|
}
|
|
2821
2963
|
function selectGoVersion(workPath) {
|
|
2822
|
-
const goMod = (0,
|
|
2823
|
-
if (!(0,
|
|
2964
|
+
const goMod = (0, import_node_path14.join)(workPath, "go.mod");
|
|
2965
|
+
if (!(0, import_node_fs10.existsSync)(goMod))
|
|
2824
2966
|
return DEFAULT_GO_VERSION;
|
|
2825
|
-
const contents = (0,
|
|
2967
|
+
const contents = (0, import_node_fs10.readFileSync)(goMod, "utf8");
|
|
2826
2968
|
const toolchain = parseImageVersion(
|
|
2827
2969
|
TOOLCHAIN_DIRECTIVE_RE.exec(contents)?.[1]
|
|
2828
2970
|
);
|
|
@@ -2844,10 +2986,10 @@ var go = {
|
|
|
2844
2986
|
},
|
|
2845
2987
|
defaultEntrypoint({ workPath, zeroConfig }) {
|
|
2846
2988
|
const candidate = GO_CANDIDATE_ENTRYPOINTS.find(
|
|
2847
|
-
(name) => (0,
|
|
2989
|
+
(name) => (0, import_node_fs10.existsSync)((0, import_node_path14.join)(workPath, name))
|
|
2848
2990
|
);
|
|
2849
2991
|
if (candidate)
|
|
2850
|
-
return
|
|
2992
|
+
return import_node_path14.posix.dirname(candidate);
|
|
2851
2993
|
if (zeroConfig) {
|
|
2852
2994
|
const last = GO_CANDIDATE_ENTRYPOINTS.length - 1;
|
|
2853
2995
|
throw new Error(
|
|
@@ -2859,8 +3001,8 @@ var go = {
|
|
|
2859
3001
|
};
|
|
2860
3002
|
|
|
2861
3003
|
// src/buildpacks/ruby.ts
|
|
2862
|
-
var
|
|
2863
|
-
var
|
|
3004
|
+
var import_node_fs11 = require("fs");
|
|
3005
|
+
var import_node_path15 = require("path");
|
|
2864
3006
|
var import_smol_toml2 = require("smol-toml");
|
|
2865
3007
|
|
|
2866
3008
|
// src/buildpacks/version.ts
|
|
@@ -2892,10 +3034,10 @@ var ruby = {
|
|
|
2892
3034
|
return { version: version2, buildImage: image, runImage: image };
|
|
2893
3035
|
},
|
|
2894
3036
|
validate({ workPath, buildEnv }) {
|
|
2895
|
-
const gemfile = (0,
|
|
2896
|
-
if (!(0,
|
|
3037
|
+
const gemfile = (0, import_node_path15.join)(workPath, "Gemfile");
|
|
3038
|
+
if (!(0, import_node_fs11.existsSync)(gemfile))
|
|
2897
3039
|
return;
|
|
2898
|
-
if (!GEMFILE_RAILS_GEM_RE.test((0,
|
|
3040
|
+
if (!GEMFILE_RAILS_GEM_RE.test((0, import_node_fs11.readFileSync)(gemfile, "utf8")))
|
|
2899
3041
|
return;
|
|
2900
3042
|
if (buildEnv?.SECRET_KEY_BASE)
|
|
2901
3043
|
return;
|
|
@@ -2906,13 +3048,13 @@ var ruby = {
|
|
|
2906
3048
|
};
|
|
2907
3049
|
function selectRubyVersion(workPath) {
|
|
2908
3050
|
for (const name of RUBY_VERSION_FILES) {
|
|
2909
|
-
const file = (0,
|
|
2910
|
-
if ((0,
|
|
2911
|
-
return parseVersionFile(name, (0,
|
|
3051
|
+
const file = (0, import_node_path15.join)(workPath, name);
|
|
3052
|
+
if ((0, import_node_fs11.existsSync)(file)) {
|
|
3053
|
+
return parseVersionFile(name, (0, import_node_fs11.readFileSync)(file, "utf8"));
|
|
2912
3054
|
}
|
|
2913
3055
|
}
|
|
2914
|
-
const gemfile = (0,
|
|
2915
|
-
return (0,
|
|
3056
|
+
const gemfile = (0, import_node_path15.join)(workPath, "Gemfile");
|
|
3057
|
+
return (0, import_node_fs11.existsSync)(gemfile) ? parseGemfileRubyVersion((0, import_node_fs11.readFileSync)(gemfile, "utf8")) : void 0;
|
|
2916
3058
|
}
|
|
2917
3059
|
function parseVersionFile(name, contents) {
|
|
2918
3060
|
let version2;
|
|
@@ -2949,13 +3091,13 @@ function parseGemfileRubyVersion(contents) {
|
|
|
2949
3091
|
}
|
|
2950
3092
|
|
|
2951
3093
|
// src/buildpacks/rust.ts
|
|
2952
|
-
var
|
|
2953
|
-
var
|
|
3094
|
+
var import_node_fs12 = require("fs");
|
|
3095
|
+
var import_node_path16 = require("path");
|
|
2954
3096
|
var import_smol_toml3 = require("smol-toml");
|
|
2955
3097
|
var DEFAULT_RUST_VERSION = "1";
|
|
2956
3098
|
var RUST_IMAGE_REPOSITORY = "docker.io/library/rust";
|
|
2957
3099
|
var RUST_BUILD_IMAGE_DISTRO = "bookworm";
|
|
2958
|
-
var RUST_RUN_IMAGE = "gcr.io/distroless/cc-debian12";
|
|
3100
|
+
var RUST_RUN_IMAGE = "gcr.io/distroless/cc-debian12@sha256:6dc8478fd8e790ae427aeff51e588573dec83b13adb7e5d10505a717927009b5";
|
|
2959
3101
|
var RUST_TOOLCHAIN_FILES = ["rust-toolchain", "rust-toolchain.toml"];
|
|
2960
3102
|
var rust = {
|
|
2961
3103
|
runtime: "rust",
|
|
@@ -2970,14 +3112,14 @@ var rust = {
|
|
|
2970
3112
|
};
|
|
2971
3113
|
},
|
|
2972
3114
|
defaultEntrypoint({ workPath, zeroConfig }) {
|
|
2973
|
-
return zeroConfig && (0,
|
|
3115
|
+
return zeroConfig && (0, import_node_fs12.existsSync)((0, import_node_path16.join)(workPath, "src/main.rs")) ? "src/main.rs" : void 0;
|
|
2974
3116
|
}
|
|
2975
3117
|
};
|
|
2976
3118
|
function selectRustVersion(workPath) {
|
|
2977
3119
|
for (const name of RUST_TOOLCHAIN_FILES) {
|
|
2978
|
-
const file = (0,
|
|
2979
|
-
if ((0,
|
|
2980
|
-
const channel = parseToolchainFile(name, (0,
|
|
3120
|
+
const file = (0, import_node_path16.join)(workPath, name);
|
|
3121
|
+
if ((0, import_node_fs12.existsSync)(file)) {
|
|
3122
|
+
const channel = parseToolchainFile(name, (0, import_node_fs12.readFileSync)(file, "utf8"));
|
|
2981
3123
|
return channel !== void 0 && isValidVersion(channel) ? channel : void 0;
|
|
2982
3124
|
}
|
|
2983
3125
|
}
|
|
@@ -3021,7 +3163,7 @@ function requestedBuildpack(config) {
|
|
|
3021
3163
|
}
|
|
3022
3164
|
function hasProjectMarkers(buildpack, workPath) {
|
|
3023
3165
|
return buildpack.projectMarkers.some(
|
|
3024
|
-
(name) => (0,
|
|
3166
|
+
(name) => (0, import_node_fs13.existsSync)((0, import_node_path17.join)(workPath, name))
|
|
3025
3167
|
);
|
|
3026
3168
|
}
|
|
3027
3169
|
|
|
@@ -3035,7 +3177,7 @@ function selectEntrypoint(params, sourceDir) {
|
|
|
3035
3177
|
return fromEnv ?? params.buildpack.defaultEntrypoint?.({ workPath: sourceDir, zeroConfig });
|
|
3036
3178
|
}
|
|
3037
3179
|
async function buildAndPushBuildpack(params) {
|
|
3038
|
-
const sourceDir = (0,
|
|
3180
|
+
const sourceDir = (0, import_node_fs14.mkdtempSync)((0, import_node_path18.join)((0, import_node_os10.tmpdir)(), "vercel-cnb-source-"));
|
|
3039
3181
|
try {
|
|
3040
3182
|
step("Staging buildpack source files");
|
|
3041
3183
|
await stageWorkspace(params, sourceDir);
|
|
@@ -3180,7 +3322,7 @@ async function buildAndPushBuildpack(params) {
|
|
|
3180
3322
|
);
|
|
3181
3323
|
} finally {
|
|
3182
3324
|
try {
|
|
3183
|
-
(0,
|
|
3325
|
+
(0, import_node_fs14.rmSync)(sourceDir, { recursive: true, force: true });
|
|
3184
3326
|
} catch {
|
|
3185
3327
|
debug(`Could not remove buildpack source snapshot ${sourceDir}.`);
|
|
3186
3328
|
}
|
|
@@ -3188,8 +3330,8 @@ async function buildAndPushBuildpack(params) {
|
|
|
3188
3330
|
}
|
|
3189
3331
|
|
|
3190
3332
|
// src/image-source.ts
|
|
3191
|
-
var
|
|
3192
|
-
var
|
|
3333
|
+
var import_node_fs15 = require("fs");
|
|
3334
|
+
var import_node_path19 = __toESM(require("path"));
|
|
3193
3335
|
var DETECT_SENTINEL = "<detect>";
|
|
3194
3336
|
function resolveImageSource(options, context) {
|
|
3195
3337
|
const { config, workPath, entrypoint } = options;
|
|
@@ -3206,8 +3348,8 @@ function resolveImageSource(options, context) {
|
|
|
3206
3348
|
}
|
|
3207
3349
|
const dockerfileConfigured = entrypointRef && isDockerfileRef(entrypointRef) ? entrypointRef : findDockerfile(workPath);
|
|
3208
3350
|
const dockerfileRel = dockerfileConfigured ?? "Dockerfile";
|
|
3209
|
-
const dockerfilePath =
|
|
3210
|
-
const hasDockerfile = dockerfileConfigured !== void 0 || !buildpack && (0,
|
|
3351
|
+
const dockerfilePath = import_node_path19.default.join(workPath, dockerfileRel);
|
|
3352
|
+
const hasDockerfile = dockerfileConfigured !== void 0 || !buildpack && (0, import_node_fs15.existsSync)(dockerfilePath);
|
|
3211
3353
|
if (hasDockerfile) {
|
|
3212
3354
|
return { kind: "dockerfile", dockerfileRel, dockerfilePath };
|
|
3213
3355
|
}
|
|
@@ -3228,7 +3370,7 @@ var import_build_utils6 = require("@vercel/build-utils");
|
|
|
3228
3370
|
var import_node_crypto8 = require("crypto");
|
|
3229
3371
|
var import_promises7 = require("fs/promises");
|
|
3230
3372
|
var import_node_os11 = require("os");
|
|
3231
|
-
var
|
|
3373
|
+
var import_node_path20 = require("path");
|
|
3232
3374
|
var BUILDAH_STORE_CACHE_DIR = ".vercel/cache/buildah-store";
|
|
3233
3375
|
var STORE_PATHS = {
|
|
3234
3376
|
graphRoot: BUILDAH_GRAPH_ROOT,
|
|
@@ -3242,7 +3384,7 @@ var BuildahStoreCache = class _BuildahStoreCache {
|
|
|
3242
3384
|
}
|
|
3243
3385
|
static forProject(options, client) {
|
|
3244
3386
|
return new _BuildahStoreCache(
|
|
3245
|
-
(0,
|
|
3387
|
+
(0, import_node_path20.resolve)(options.repoRootPath || options.workPath),
|
|
3246
3388
|
client
|
|
3247
3389
|
);
|
|
3248
3390
|
}
|
|
@@ -3319,7 +3461,7 @@ var BuildahStoreCache = class _BuildahStoreCache {
|
|
|
3319
3461
|
return {};
|
|
3320
3462
|
}
|
|
3321
3463
|
return await (0, import_build_utils6.glob)(
|
|
3322
|
-
`${BUILDAH_STORE_CACHE_DIR}/${(0,
|
|
3464
|
+
`${BUILDAH_STORE_CACHE_DIR}/${(0, import_node_path20.basename)(archive)}`,
|
|
3323
3465
|
this.repositoryRoot
|
|
3324
3466
|
);
|
|
3325
3467
|
} catch (error) {
|
|
@@ -3341,7 +3483,7 @@ var BuildahStoreCache = class _BuildahStoreCache {
|
|
|
3341
3483
|
}
|
|
3342
3484
|
async archivePath(options) {
|
|
3343
3485
|
const key = await snapshotKey(this.client);
|
|
3344
|
-
return (0,
|
|
3486
|
+
return (0, import_node_path20.join)(await this.snapshotDirectory(options), `store-${key}.tar.zst`);
|
|
3345
3487
|
}
|
|
3346
3488
|
async snapshotDirectory({
|
|
3347
3489
|
create
|
|
@@ -3349,7 +3491,7 @@ var BuildahStoreCache = class _BuildahStoreCache {
|
|
|
3349
3491
|
const root = await (0, import_promises7.realpath)(this.repositoryRoot);
|
|
3350
3492
|
let directory = root;
|
|
3351
3493
|
for (const part of BUILDAH_STORE_CACHE_DIR.split("/")) {
|
|
3352
|
-
directory = (0,
|
|
3494
|
+
directory = (0, import_node_path20.join)(directory, part);
|
|
3353
3495
|
if (create) {
|
|
3354
3496
|
await (0, import_promises7.mkdir)(directory, { mode: 448 }).catch((error) => {
|
|
3355
3497
|
if (error.code !== "EEXIST")
|
|
@@ -3358,7 +3500,7 @@ var BuildahStoreCache = class _BuildahStoreCache {
|
|
|
3358
3500
|
}
|
|
3359
3501
|
const stats = await lstatIfPresent(directory);
|
|
3360
3502
|
if (!stats) {
|
|
3361
|
-
return (0,
|
|
3503
|
+
return (0, import_node_path20.join)(root, BUILDAH_STORE_CACHE_DIR);
|
|
3362
3504
|
}
|
|
3363
3505
|
if (!stats.isDirectory()) {
|
|
3364
3506
|
throw new Error(`${directory} is not a directory`);
|
|
@@ -3370,7 +3512,7 @@ var BuildahStoreCache = class _BuildahStoreCache {
|
|
|
3370
3512
|
async function restoreStore(archive) {
|
|
3371
3513
|
const storeLock = await requireStoreLock();
|
|
3372
3514
|
const state = await createBuildahStoreStateDirectory();
|
|
3373
|
-
const gate = new FileLock((0,
|
|
3515
|
+
const gate = new FileLock((0, import_node_path20.join)(state, "restore.lock"));
|
|
3374
3516
|
return runStoreCommand(
|
|
3375
3517
|
{
|
|
3376
3518
|
action: "restore",
|
|
@@ -3378,7 +3520,7 @@ async function restoreStore(archive) {
|
|
|
3378
3520
|
...STORE_PATHS,
|
|
3379
3521
|
archive,
|
|
3380
3522
|
storeLock: storeLock.path,
|
|
3381
|
-
marker: (0,
|
|
3523
|
+
marker: (0, import_node_path20.join)(state, "restored")
|
|
3382
3524
|
}
|
|
3383
3525
|
},
|
|
3384
3526
|
gate
|
|
@@ -3424,8 +3566,8 @@ async function snapshotKey(client) {
|
|
|
3424
3566
|
[
|
|
3425
3567
|
"/usr/share/containers/storage.conf",
|
|
3426
3568
|
"/etc/containers/storage.conf",
|
|
3427
|
-
(0,
|
|
3428
|
-
process.env.XDG_CONFIG_HOME || (0,
|
|
3569
|
+
(0, import_node_path20.join)(
|
|
3570
|
+
process.env.XDG_CONFIG_HOME || (0, import_node_path20.join)((0, import_node_os11.homedir)(), ".config"),
|
|
3429
3571
|
"containers/storage.conf"
|
|
3430
3572
|
),
|
|
3431
3573
|
process.env.CONTAINERS_STORAGE_CONF,
|
|
@@ -3466,9 +3608,9 @@ function failureReason(error) {
|
|
|
3466
3608
|
|
|
3467
3609
|
// src/dev.ts
|
|
3468
3610
|
var import_node_child_process4 = require("child_process");
|
|
3469
|
-
var
|
|
3611
|
+
var import_node_fs16 = require("fs");
|
|
3470
3612
|
var import_node_os12 = require("os");
|
|
3471
|
-
var
|
|
3613
|
+
var import_node_path21 = __toESM(require("path"));
|
|
3472
3614
|
var HOST_ONLY_ENV = /* @__PURE__ */ new Set([
|
|
3473
3615
|
"TMPDIR",
|
|
3474
3616
|
"TMP",
|
|
@@ -3498,8 +3640,8 @@ function isHostOnlyEnvVar(key) {
|
|
|
3498
3640
|
return HOST_ONLY_ENV.has(key) || key.startsWith("__") || key.startsWith("XPC_") || key.startsWith("SSH_") || key.startsWith("Apple");
|
|
3499
3641
|
}
|
|
3500
3642
|
function writeEnvFile(env) {
|
|
3501
|
-
const dir = (0,
|
|
3502
|
-
const file =
|
|
3643
|
+
const dir = (0, import_node_fs16.mkdtempSync)(import_node_path21.default.join((0, import_node_os12.tmpdir)(), "vercel-container-dev-env-"));
|
|
3644
|
+
const file = import_node_path21.default.join(dir, "env");
|
|
3503
3645
|
const lines = [];
|
|
3504
3646
|
for (const [key, value] of Object.entries(env)) {
|
|
3505
3647
|
if (value.includes("\n")) {
|
|
@@ -3507,7 +3649,7 @@ function writeEnvFile(env) {
|
|
|
3507
3649
|
}
|
|
3508
3650
|
lines.push(`${key}=${value}`);
|
|
3509
3651
|
}
|
|
3510
|
-
(0,
|
|
3652
|
+
(0, import_node_fs16.writeFileSync)(file, `${lines.join("\n")}
|
|
3511
3653
|
`);
|
|
3512
3654
|
return file;
|
|
3513
3655
|
}
|
|
@@ -3598,14 +3740,14 @@ async function resolveDevImage(options, out, span) {
|
|
|
3598
3740
|
);
|
|
3599
3741
|
}
|
|
3600
3742
|
const { dockerfilePath } = source;
|
|
3601
|
-
if (!(0,
|
|
3743
|
+
if (!(0, import_node_fs16.existsSync)(dockerfilePath)) {
|
|
3602
3744
|
throw new Error(
|
|
3603
3745
|
`Dockerfile not found at "${dockerfilePath}" for container service.`
|
|
3604
3746
|
);
|
|
3605
3747
|
}
|
|
3606
3748
|
const serviceName = options.service?.name ?? "service";
|
|
3607
3749
|
const tag = devImageTag(serviceName);
|
|
3608
|
-
const contextDir =
|
|
3750
|
+
const contextDir = import_node_path21.default.dirname(dockerfilePath);
|
|
3609
3751
|
const buildArgFlags2 = [];
|
|
3610
3752
|
const buildEnv = options.meta?.buildEnv ?? {};
|
|
3611
3753
|
for (const [key, value] of Object.entries(buildEnv)) {
|
|
@@ -3810,7 +3952,7 @@ async function startContainer(options, reuseKey) {
|
|
|
3810
3952
|
}
|
|
3811
3953
|
});
|
|
3812
3954
|
const cleanupEnvFile = () => {
|
|
3813
|
-
(0,
|
|
3955
|
+
(0, import_node_fs16.rmSync)(import_node_path21.default.dirname(envFilePath), { recursive: true, force: true });
|
|
3814
3956
|
};
|
|
3815
3957
|
const shutdown = async () => {
|
|
3816
3958
|
runningContainers.delete(reuseKey);
|
|
@@ -3887,9 +4029,9 @@ async function startContainer(options, reuseKey) {
|
|
|
3887
4029
|
|
|
3888
4030
|
// src/prepare-cache.ts
|
|
3889
4031
|
var import_build_utils7 = require("@vercel/build-utils");
|
|
3890
|
-
var
|
|
4032
|
+
var import_node_path22 = require("path");
|
|
3891
4033
|
async function prepareCache(options) {
|
|
3892
|
-
const root = (0,
|
|
4034
|
+
const root = (0, import_node_path22.resolve)(options.repoRootPath || options.workPath);
|
|
3893
4035
|
const buildpackFiles = await collectBuildpackCache(root);
|
|
3894
4036
|
const buildahStoreFiles = await BuildahStoreCache.forProject(
|
|
3895
4037
|
options,
|
|
@@ -4085,19 +4227,19 @@ async function buildAndPushImage(params) {
|
|
|
4085
4227
|
);
|
|
4086
4228
|
}
|
|
4087
4229
|
function resolveDaemonContextDir(options, daemon) {
|
|
4088
|
-
const contextDir =
|
|
4230
|
+
const contextDir = import_node_path23.default.join(options.workPath, daemon.root);
|
|
4089
4231
|
const real = (p) => {
|
|
4090
4232
|
try {
|
|
4091
|
-
return (0,
|
|
4233
|
+
return (0, import_node_fs17.realpathSync)(p);
|
|
4092
4234
|
} catch {
|
|
4093
|
-
return
|
|
4235
|
+
return import_node_path23.default.resolve(p);
|
|
4094
4236
|
}
|
|
4095
4237
|
};
|
|
4096
|
-
const relative3 =
|
|
4238
|
+
const relative3 = import_node_path23.default.relative(
|
|
4097
4239
|
real(options.repoRootPath || options.workPath),
|
|
4098
4240
|
real(contextDir)
|
|
4099
4241
|
);
|
|
4100
|
-
if (
|
|
4242
|
+
if (import_node_path23.default.isAbsolute(relative3) || relative3 === ".." || relative3.startsWith(`..${import_node_path23.default.sep}`)) {
|
|
4101
4243
|
throw new Error(
|
|
4102
4244
|
`Daemon "${daemon.name}" has root "${daemon.root}", which is outside the repository.`
|
|
4103
4245
|
);
|
|
@@ -4163,22 +4305,22 @@ async function resolveImageHandler(options, source, buildahClient, span, schedul
|
|
|
4163
4305
|
if (meta?.isDev) {
|
|
4164
4306
|
const serviceName = options.service?.name;
|
|
4165
4307
|
const tag2 = devImageTag(
|
|
4166
|
-
serviceName ??
|
|
4308
|
+
serviceName ?? import_node_path23.default.basename(dockerfileRel).split(".")[0]
|
|
4167
4309
|
);
|
|
4168
4310
|
span?.setAttributes({ "container.mode": "dev", "image.tag": tag2 });
|
|
4169
4311
|
return tag2;
|
|
4170
4312
|
}
|
|
4171
|
-
if (!(0,
|
|
4313
|
+
if (!(0, import_node_fs17.existsSync)(dockerfilePath)) {
|
|
4172
4314
|
throw new Error(
|
|
4173
4315
|
`Dockerfile not found at "${dockerfilePath}" for container service.`
|
|
4174
4316
|
);
|
|
4175
4317
|
}
|
|
4176
4318
|
const repository = daemon ? (0, import_build_utils8.getDaemonImageRepository)(daemon.name) : sanitizeRepository(
|
|
4177
|
-
options.service?.name ??
|
|
4319
|
+
options.service?.name ?? import_node_path23.default.basename(dockerfileRel).split(".")[0]
|
|
4178
4320
|
);
|
|
4179
4321
|
const tag = resolveImageTag();
|
|
4180
|
-
const contextDir = daemon ? resolveDaemonContextDir(options, daemon) : schedulesCommand ?
|
|
4181
|
-
const contextIsRoot = Boolean(daemon || schedulesCommand) ||
|
|
4322
|
+
const contextDir = daemon ? resolveDaemonContextDir(options, daemon) : schedulesCommand ? import_node_path23.default.join(options.workPath, schedulesCommand.root) : import_node_path23.default.dirname(dockerfilePath);
|
|
4323
|
+
const contextIsRoot = Boolean(daemon || schedulesCommand) || import_node_path23.default.dirname(import_node_path23.default.normalize(dockerfileRel)) === ".";
|
|
4182
4324
|
const buildArgs = buildArgsFromEnv(meta?.buildEnv);
|
|
4183
4325
|
span?.setAttributes({
|
|
4184
4326
|
"container.mode": "build_and_push",
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/container",
|
|
3
|
-
"version": "24.0.0
|
|
3
|
+
"version": "24.0.0",
|
|
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.2.0
|
|
20
|
+
"@vercel/build-utils": "15.2.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "20.11.0",
|
|
24
24
|
"vitest": "4.1.10",
|
|
25
|
-
"@vercel/
|
|
26
|
-
"@vercel
|
|
25
|
+
"@vercel-internals/ipc-proxy": "1.1.1",
|
|
26
|
+
"@vercel/build-utils": "15.2.0"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build": "node build.mjs",
|
|
33
33
|
"type-check": "tsc --noEmit",
|
|
34
34
|
"test": "vitest run --config ../../vitest.config.mts",
|
|
35
|
-
"test-unit": "node test-go.mjs && 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 test/buildah-store-cache.test.ts test/buildah-store-command.test.ts test/buildah-debug.test.ts test/schedules-command.test.ts",
|
|
35
|
+
"test-unit": "node test-go.mjs && 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 test/buildah-store-cache.test.ts test/buildah-store-command.test.ts test/buildah-debug.test.ts test/schedules-command.test.ts test/build-user.test.ts",
|
|
36
36
|
"test-e2e": "vitest run --config ../../vitest.config.mts test/e2e.test.ts"
|
|
37
37
|
}
|
|
38
38
|
}
|