@vercel/container 18.0.1 → 19.1.1
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 +27 -32
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ async function generateProjectManifest({
|
|
|
62
62
|
var diagnostics = (0, import_build_utils.createDiagnostics)("container");
|
|
63
63
|
|
|
64
64
|
// src/index.ts
|
|
65
|
-
var
|
|
65
|
+
var import_node_fs16 = require("fs");
|
|
66
66
|
var import_node_path17 = __toESM(require("path"));
|
|
67
67
|
|
|
68
68
|
// src/util.ts
|
|
@@ -124,7 +124,7 @@ function readString(value) {
|
|
|
124
124
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
125
125
|
}
|
|
126
126
|
function isDockerfileRef(ref) {
|
|
127
|
-
return
|
|
127
|
+
return /(docker|container)file/i.test((0, import_node_path.basename)(ref));
|
|
128
128
|
}
|
|
129
129
|
var DOCKERFILE_CANDIDATES = [
|
|
130
130
|
"Dockerfile.vercel",
|
|
@@ -1248,27 +1248,24 @@ var BUILDPACK_CACHE_DIR = ".vercel/cache/buildpacks";
|
|
|
1248
1248
|
var CNB_COMMITTED_DIR = "committed";
|
|
1249
1249
|
var CNB_CACHE_METADATA_FILE = "io.buildpacks.lifecycle.cache.metadata";
|
|
1250
1250
|
var IMAGE_ID_FILE = "image-id";
|
|
1251
|
-
function buildpackCacheEnabled() {
|
|
1252
|
-
return readString(process.env.VERCEL_ENABLE_BUILDPACK_CACHE) === "1";
|
|
1253
|
-
}
|
|
1254
1251
|
function buildpackCacheDir(options) {
|
|
1255
1252
|
const root = (0, import_node_path4.resolve)(options.repoRootPath || options.workPath);
|
|
1256
1253
|
const app = (0, import_node_path4.relative)(root, (0, import_node_path4.resolve)(options.workPath)).split(import_node_path4.sep).join("/") || ".";
|
|
1257
1254
|
const key = (0, import_node_crypto2.createHash)("sha256").update(JSON.stringify([app, options.service?.name ?? null])).digest("hex").slice(0, 32);
|
|
1258
1255
|
return (0, import_node_path4.join)(root, BUILDPACK_CACHE_DIR, key);
|
|
1259
1256
|
}
|
|
1260
|
-
async function restoreBuildpackCache(dir,
|
|
1257
|
+
async function restoreBuildpackCache(dir, cacheKey, cacheDir) {
|
|
1261
1258
|
const committed = (0, import_node_path4.join)(cacheDir, CNB_COMMITTED_DIR);
|
|
1262
|
-
const [copy,
|
|
1259
|
+
const [copy, key] = await Promise.allSettled([
|
|
1263
1260
|
copyCommitted(dir, cacheDir),
|
|
1264
|
-
|
|
1261
|
+
cacheKey
|
|
1265
1262
|
]);
|
|
1266
1263
|
try {
|
|
1267
1264
|
if (copy.status === "rejected")
|
|
1268
1265
|
throw copy.reason;
|
|
1269
|
-
if (
|
|
1270
|
-
throw
|
|
1271
|
-
if (readRegularFile((0, import_node_path4.join)(dir, IMAGE_ID_FILE)) !==
|
|
1266
|
+
if (key.status === "rejected")
|
|
1267
|
+
throw key.reason;
|
|
1268
|
+
if (readRegularFile((0, import_node_path4.join)(dir, IMAGE_ID_FILE)) !== key.value) {
|
|
1272
1269
|
(0, import_node_fs4.rmSync)(committed, { recursive: true, force: true });
|
|
1273
1270
|
return { status: "miss", reason: "base_image_changed" };
|
|
1274
1271
|
}
|
|
@@ -1282,7 +1279,7 @@ async function restoreBuildpackCache(dir, imageId, cacheDir) {
|
|
|
1282
1279
|
};
|
|
1283
1280
|
}
|
|
1284
1281
|
}
|
|
1285
|
-
async function saveBuildpackCache(dir,
|
|
1282
|
+
async function saveBuildpackCache(dir, cacheKey, cacheDir) {
|
|
1286
1283
|
const committed = (0, import_node_path4.join)(cacheDir, CNB_COMMITTED_DIR);
|
|
1287
1284
|
let metadata;
|
|
1288
1285
|
try {
|
|
@@ -1296,12 +1293,12 @@ async function saveBuildpackCache(dir, imageId, cacheDir) {
|
|
|
1296
1293
|
};
|
|
1297
1294
|
}
|
|
1298
1295
|
try {
|
|
1299
|
-
if (isSaved(dir,
|
|
1296
|
+
if (isSaved(dir, cacheKey, metadata))
|
|
1300
1297
|
return { status: "unchanged" };
|
|
1301
1298
|
const bytes = sizeOf(committed);
|
|
1302
1299
|
(0, import_node_fs4.rmSync)(dir, { recursive: true, force: true });
|
|
1303
1300
|
await copyCommitted(cacheDir, dir);
|
|
1304
|
-
(0, import_node_fs4.writeFileSync)((0, import_node_path4.join)(dir, IMAGE_ID_FILE),
|
|
1301
|
+
(0, import_node_fs4.writeFileSync)((0, import_node_path4.join)(dir, IMAGE_ID_FILE), cacheKey);
|
|
1305
1302
|
return { status: "saved", bytes };
|
|
1306
1303
|
} catch (error) {
|
|
1307
1304
|
try {
|
|
@@ -1311,11 +1308,11 @@ async function saveBuildpackCache(dir, imageId, cacheDir) {
|
|
|
1311
1308
|
return { status: "skipped", reason: firstLine(error) };
|
|
1312
1309
|
}
|
|
1313
1310
|
}
|
|
1314
|
-
function isSaved(dir,
|
|
1311
|
+
function isSaved(dir, cacheKey, metadata) {
|
|
1315
1312
|
try {
|
|
1316
1313
|
const committed = (0, import_node_path4.join)(dir, CNB_COMMITTED_DIR);
|
|
1317
1314
|
assertDirectory(committed);
|
|
1318
|
-
return readRegularFile((0, import_node_path4.join)(dir, IMAGE_ID_FILE)) ===
|
|
1315
|
+
return readRegularFile((0, import_node_path4.join)(dir, IMAGE_ID_FILE)) === cacheKey && readRegularFile((0, import_node_path4.join)(committed, CNB_CACHE_METADATA_FILE)) === metadata;
|
|
1319
1316
|
} catch {
|
|
1320
1317
|
return false;
|
|
1321
1318
|
}
|
|
@@ -1426,18 +1423,18 @@ var distribution_default = {
|
|
|
1426
1423
|
buildpacks: {
|
|
1427
1424
|
ruby: {
|
|
1428
1425
|
id: "vercel/ruby",
|
|
1429
|
-
version: "0.3.
|
|
1430
|
-
sha256: "
|
|
1426
|
+
version: "0.3.1",
|
|
1427
|
+
sha256: "359615b41797247e5158c7bbcd97763322fcca6836823acd6e981d4c89d432a7"
|
|
1431
1428
|
},
|
|
1432
1429
|
go: {
|
|
1433
1430
|
id: "vercel/go",
|
|
1434
|
-
version: "0.1
|
|
1435
|
-
sha256: "
|
|
1431
|
+
version: "0.2.1",
|
|
1432
|
+
sha256: "6013ede7620734cb20885d3a6aecd7f14e364e941862a3074340cf1bbe648cc0"
|
|
1436
1433
|
},
|
|
1437
1434
|
rust: {
|
|
1438
1435
|
id: "vercel/rust",
|
|
1439
|
-
version: "0.
|
|
1440
|
-
sha256: "
|
|
1436
|
+
version: "0.2.2",
|
|
1437
|
+
sha256: "e6c1d59f759599bacdcbf5f077b6a5bba6e557481827fe23045925b9c2d39032"
|
|
1441
1438
|
}
|
|
1442
1439
|
}
|
|
1443
1440
|
};
|
|
@@ -2769,7 +2766,7 @@ async function buildAndPushBuildpack(params) {
|
|
|
2769
2766
|
"image.ref": target.imageRef,
|
|
2770
2767
|
"registry.username": target.username
|
|
2771
2768
|
});
|
|
2772
|
-
const cache =
|
|
2769
|
+
const cache = engine.name === "buildah" ? { dir: buildpackCacheDir(params) } : void 0;
|
|
2773
2770
|
if (cache)
|
|
2774
2771
|
debug(`buildpack cache: ${cache.dir}`);
|
|
2775
2772
|
buildSpan?.setAttributes({
|
|
@@ -3316,14 +3313,9 @@ async function startContainer(options, reuseKey) {
|
|
|
3316
3313
|
|
|
3317
3314
|
// src/prepare-cache.ts
|
|
3318
3315
|
var import_build_utils5 = require("@vercel/build-utils");
|
|
3319
|
-
var import_node_fs16 = require("fs");
|
|
3320
3316
|
var import_node_path16 = require("path");
|
|
3321
3317
|
async function prepareCache(options) {
|
|
3322
3318
|
const root = (0, import_node_path16.resolve)(options.repoRootPath || options.workPath);
|
|
3323
|
-
if (!buildpackCacheEnabled()) {
|
|
3324
|
-
(0, import_node_fs16.rmSync)((0, import_node_path16.join)(root, BUILDPACK_CACHE_DIR), { recursive: true, force: true });
|
|
3325
|
-
return {};
|
|
3326
|
-
}
|
|
3327
3319
|
const start = Date.now();
|
|
3328
3320
|
const files = await (0, import_build_utils5.glob)(`${BUILDPACK_CACHE_DIR}/**`, root);
|
|
3329
3321
|
const count = Object.keys(files).length;
|
|
@@ -3538,7 +3530,6 @@ async function resolveImageHandler(options, source, span) {
|
|
|
3538
3530
|
config,
|
|
3539
3531
|
meta,
|
|
3540
3532
|
buildEnv: buildArgsFromEnv(meta?.buildEnv),
|
|
3541
|
-
cache: buildpackCacheEnabled(),
|
|
3542
3533
|
parentSpan: span
|
|
3543
3534
|
});
|
|
3544
3535
|
}
|
|
@@ -3551,7 +3542,7 @@ async function resolveImageHandler(options, source, span) {
|
|
|
3551
3542
|
span?.setAttributes({ "container.mode": "dev", "image.tag": tag2 });
|
|
3552
3543
|
return tag2;
|
|
3553
3544
|
}
|
|
3554
|
-
if (!(0,
|
|
3545
|
+
if (!(0, import_node_fs16.existsSync)(dockerfilePath)) {
|
|
3555
3546
|
throw new Error(
|
|
3556
3547
|
`Dockerfile not found at "${dockerfilePath}" for container service.`
|
|
3557
3548
|
);
|
|
@@ -3605,9 +3596,13 @@ async function build(options) {
|
|
|
3605
3596
|
[daemon.name]: {
|
|
3606
3597
|
runtime: "container",
|
|
3607
3598
|
image,
|
|
3608
|
-
|
|
3599
|
+
// Checked by vercel.json validation: a daemon sets one of them.
|
|
3600
|
+
instances: daemon.instances ?? daemon.replicas,
|
|
3609
3601
|
...daemon.command && { command: daemon.command },
|
|
3610
|
-
...daemon.resources && { resources: daemon.resources }
|
|
3602
|
+
...daemon.resources && { resources: daemon.resources },
|
|
3603
|
+
...daemon.terminationGracePeriodSeconds !== void 0 && {
|
|
3604
|
+
terminationGracePeriodSeconds: daemon.terminationGracePeriodSeconds
|
|
3605
|
+
}
|
|
3611
3606
|
}
|
|
3612
3607
|
}
|
|
3613
3608
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/container",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.1.1",
|
|
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.
|
|
20
|
+
"@vercel/build-utils": "14.21.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "20.11.0",
|
|
24
24
|
"vitest": "4.1.10",
|
|
25
|
-
"@vercel/build-utils": "14.
|
|
25
|
+
"@vercel/build-utils": "14.21.1"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|