@vercel/container 23.0.0 → 23.0.1-snapshot-8a613d8ad85d
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 +23 -6
- package/dist/schedules-command-dispatcher +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,8 +47,8 @@ var import_node_path = require("path");
|
|
|
47
47
|
var SCHEDULES_COMMAND_ENV = "VERCEL_SCHEDULE_COMMAND";
|
|
48
48
|
var DISPATCHER = "schedules-command-dispatcher";
|
|
49
49
|
async function buildSchedulesCommandImage(engine, params, dispatcher = (0, import_node_path.join)(__dirname, DISPATCHER)) {
|
|
50
|
-
await engine.build(params);
|
|
51
|
-
if ((await engine.onBuildTriggers?.(
|
|
50
|
+
const baseImage = await engine.build(params);
|
|
51
|
+
if ((await engine.onBuildTriggers?.(baseImage))?.length) {
|
|
52
52
|
throw new Error(
|
|
53
53
|
`"${params.dockerfilePath}" declares ONBUILD instructions, which only run when another image is built from it. Remove them from the schedule's Dockerfile.`
|
|
54
54
|
);
|
|
@@ -60,7 +60,7 @@ async function buildSchedulesCommandImage(engine, params, dispatcher = (0, impor
|
|
|
60
60
|
await (0, import_promises.writeFile)(
|
|
61
61
|
dockerfilePath,
|
|
62
62
|
[
|
|
63
|
-
`FROM ${
|
|
63
|
+
`FROM ${baseImage}`,
|
|
64
64
|
`COPY --chmod=0555 ${DISPATCHER} /__vercel_runtime/${DISPATCHER}`,
|
|
65
65
|
`ENTRYPOINT ["/__vercel_runtime/${DISPATCHER}"]`
|
|
66
66
|
].join("\n")
|
|
@@ -69,7 +69,8 @@ async function buildSchedulesCommandImage(engine, params, dispatcher = (0, impor
|
|
|
69
69
|
...params,
|
|
70
70
|
contextDir,
|
|
71
71
|
dockerfilePath,
|
|
72
|
-
buildArgs: void 0
|
|
72
|
+
buildArgs: void 0,
|
|
73
|
+
baseImageIsLocal: true
|
|
73
74
|
});
|
|
74
75
|
} finally {
|
|
75
76
|
await (0, import_promises.rm)(contextDir, { recursive: true, force: true });
|
|
@@ -766,6 +767,12 @@ function localImageRef(params) {
|
|
|
766
767
|
}
|
|
767
768
|
return `${imageRef.slice(0, imageRef.lastIndexOf(":"))}:vercel-buildah-store`;
|
|
768
769
|
}
|
|
770
|
+
function pullFlags(params) {
|
|
771
|
+
if (params.baseImageIsLocal) {
|
|
772
|
+
return ["--pull=never"];
|
|
773
|
+
}
|
|
774
|
+
return params.useBuildahStoreCache ? ["--pull=always"] : [];
|
|
775
|
+
}
|
|
769
776
|
async function deploymentSourceDateEpoch() {
|
|
770
777
|
if ((0, import_build_utils3.resolveBuildConcurrency)() <= 1) {
|
|
771
778
|
return void 0;
|
|
@@ -876,7 +883,7 @@ function createBuildahEngine(client) {
|
|
|
876
883
|
// stage behind, which stops the store cache from being saved.
|
|
877
884
|
"--force-rm",
|
|
878
885
|
...sourceDateEpoch ? ["--source-date-epoch", sourceDateEpoch] : [],
|
|
879
|
-
...params
|
|
886
|
+
...pullFlags(params),
|
|
880
887
|
// Use the host network namespace for RUN steps. The build runs inside a
|
|
881
888
|
// restricted Hive cell that cannot program iptables, so buildah's default
|
|
882
889
|
// rootless networking (netavark) fails with
|
|
@@ -896,6 +903,7 @@ function createBuildahEngine(client) {
|
|
|
896
903
|
() => imageIdsFromBuildOutput(`${stdout}
|
|
897
904
|
${stderr}`)
|
|
898
905
|
);
|
|
906
|
+
return localImageRef(params);
|
|
899
907
|
},
|
|
900
908
|
async login(params) {
|
|
901
909
|
try {
|
|
@@ -1245,6 +1253,7 @@ ${version2.trim()}`);
|
|
|
1245
1253
|
params.dockerfilePath,
|
|
1246
1254
|
params.contextDir
|
|
1247
1255
|
]);
|
|
1256
|
+
return params.imageRef;
|
|
1248
1257
|
},
|
|
1249
1258
|
async onBuildTriggers(imageRef) {
|
|
1250
1259
|
const { stdout } = await runDocker([
|
|
@@ -4037,7 +4046,13 @@ async function buildAndPushImage(params) {
|
|
|
4037
4046
|
buildSpan,
|
|
4038
4047
|
"container.image_build",
|
|
4039
4048
|
{ "image.ref": imageRef, "image.platform": TARGET_PLATFORM },
|
|
4040
|
-
() =>
|
|
4049
|
+
async () => {
|
|
4050
|
+
if (params.schedulesCommand) {
|
|
4051
|
+
await buildSchedulesCommandImage(engine, buildParams);
|
|
4052
|
+
} else {
|
|
4053
|
+
await engine.build(buildParams);
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4041
4056
|
);
|
|
4042
4057
|
done(`built in ${elapsed(buildStart)}`);
|
|
4043
4058
|
const pushStart = Date.now();
|
|
@@ -4143,10 +4158,12 @@ async function resolveImageHandler(options, source, buildahClient, span, schedul
|
|
|
4143
4158
|
);
|
|
4144
4159
|
const tag = resolveImageTag();
|
|
4145
4160
|
const contextDir = schedulesCommand ? import_node_path22.default.join(options.workPath, schedulesCommand.root) : import_node_path22.default.dirname(dockerfilePath);
|
|
4161
|
+
const contextIsRoot = Boolean(schedulesCommand) || import_node_path22.default.dirname(import_node_path22.default.normalize(daemon ? daemon.entrypoint : dockerfileRel)) === ".";
|
|
4146
4162
|
const buildArgs = buildArgsFromEnv(meta?.buildEnv);
|
|
4147
4163
|
span?.setAttributes({
|
|
4148
4164
|
"container.mode": "build_and_push",
|
|
4149
4165
|
"container.repository": repository,
|
|
4166
|
+
"container.context_is_root": toTag(contextIsRoot),
|
|
4150
4167
|
"image.tag": tag
|
|
4151
4168
|
});
|
|
4152
4169
|
return buildAndPushImage({
|
|
Binary file
|