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