@vercel/container 0.0.1 → 0.0.3
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 +19 -17
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -36,7 +36,6 @@ __export(src_exports, {
|
|
|
36
36
|
version: () => version
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(src_exports);
|
|
39
|
-
var import_build_utils3 = require("@vercel/build-utils");
|
|
40
39
|
var import_node_fs6 = require("fs");
|
|
41
40
|
var import_node_path6 = __toESM(require("path"));
|
|
42
41
|
|
|
@@ -84,6 +83,10 @@ function toTag(value) {
|
|
|
84
83
|
function readString(value) {
|
|
85
84
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
86
85
|
}
|
|
86
|
+
function isDockerfileRef(ref) {
|
|
87
|
+
const base = (0, import_node_path.basename)(ref).toLowerCase();
|
|
88
|
+
return base === "dockerfile" || base === "containerfile" || base === "dockerfile.vercel" || base === "containerfile.vercel";
|
|
89
|
+
}
|
|
87
90
|
function run(cmd, args, opts = {}) {
|
|
88
91
|
return new Promise((resolve, reject) => {
|
|
89
92
|
const child = (0, import_node_child_process.spawn)(cmd, args, {
|
|
@@ -1148,10 +1151,6 @@ function devImageTag(serviceName) {
|
|
|
1148
1151
|
const safe = serviceName.toLowerCase().replace(/[^a-z0-9-_.]/g, "-");
|
|
1149
1152
|
return `vercel-dev/${safe || "service"}:dev`;
|
|
1150
1153
|
}
|
|
1151
|
-
function isDockerfileRef(ref) {
|
|
1152
|
-
const base = import_node_path4.default.basename(ref).toLowerCase();
|
|
1153
|
-
return base === "dockerfile" || base === "containerfile" || base.endsWith(".dockerfile");
|
|
1154
|
-
}
|
|
1155
1154
|
function normalizeCommand(command) {
|
|
1156
1155
|
if (typeof command === "string") {
|
|
1157
1156
|
return [command];
|
|
@@ -1401,9 +1400,11 @@ function normalizeCommand2(command) {
|
|
|
1401
1400
|
}
|
|
1402
1401
|
return void 0;
|
|
1403
1402
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
return
|
|
1403
|
+
var DOCKERFILE_CANDIDATES = ["Dockerfile.vercel", "Containerfile.vercel"];
|
|
1404
|
+
function findDockerfile(workPath) {
|
|
1405
|
+
return DOCKERFILE_CANDIDATES.find(
|
|
1406
|
+
(name) => (0, import_node_fs6.existsSync)(import_node_path6.default.join(workPath, name))
|
|
1407
|
+
);
|
|
1407
1408
|
}
|
|
1408
1409
|
function sanitizeRepository(name) {
|
|
1409
1410
|
const sanitized = name.toLowerCase().replace(/[^a-z0-9-_./]/g, "-").replace(/-+/g, "-").replace(/(^[-/.]+)|([-/.]+$)/g, "");
|
|
@@ -1568,7 +1569,7 @@ async function buildAndPushImage(params) {
|
|
|
1568
1569
|
async function resolveImageHandler(options, span) {
|
|
1569
1570
|
const { config, workPath, entrypoint, meta } = options;
|
|
1570
1571
|
const entrypointRef = readString(entrypoint);
|
|
1571
|
-
const dockerfileConfigured = entrypointRef &&
|
|
1572
|
+
const dockerfileConfigured = entrypointRef && isDockerfileRef(entrypointRef) ? entrypointRef : findDockerfile(workPath);
|
|
1572
1573
|
const dockerfileRel = dockerfileConfigured ?? "Dockerfile";
|
|
1573
1574
|
const dockerfilePath = import_node_path6.default.join(workPath, dockerfileRel);
|
|
1574
1575
|
const hasDockerfile = dockerfileConfigured !== void 0 || (0, import_node_fs6.existsSync)(dockerfilePath);
|
|
@@ -1603,12 +1604,9 @@ async function resolveImageHandler(options, span) {
|
|
|
1603
1604
|
);
|
|
1604
1605
|
}
|
|
1605
1606
|
const serviceName = options.service?.name;
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
);
|
|
1610
|
-
}
|
|
1611
|
-
const repository = sanitizeRepository(serviceName);
|
|
1607
|
+
const repository = sanitizeRepository(
|
|
1608
|
+
serviceName ?? import_node_path6.default.basename(dockerfileRel).split(".")[0]
|
|
1609
|
+
);
|
|
1612
1610
|
const tag = resolveImageTag();
|
|
1613
1611
|
const contextDir = import_node_path6.default.dirname(dockerfilePath);
|
|
1614
1612
|
const buildArgs = buildArgsFromEnv(meta?.buildEnv);
|
|
@@ -1646,10 +1644,14 @@ async function build(options) {
|
|
|
1646
1644
|
(span) => resolveImageHandler(options, span)
|
|
1647
1645
|
);
|
|
1648
1646
|
const command = normalizeCommand2(options.config.command);
|
|
1649
|
-
const
|
|
1647
|
+
const routes = [
|
|
1648
|
+
{ handle: "filesystem" },
|
|
1649
|
+
{ src: "/(.*)", dest: "/index" }
|
|
1650
|
+
];
|
|
1650
1651
|
return {
|
|
1652
|
+
routes,
|
|
1651
1653
|
output: {
|
|
1652
|
-
|
|
1654
|
+
index: {
|
|
1653
1655
|
type: "Lambda",
|
|
1654
1656
|
files: {},
|
|
1655
1657
|
// For `runtime: 'container'` the OCI image reference is carried in
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/container",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "20.11.0",
|
|
17
17
|
"vitest": "2.0.3",
|
|
18
|
-
"@vercel/build-utils": "13.32.
|
|
18
|
+
"@vercel/build-utils": "13.32.1"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|