diff --git a/.github/DockerfileBackendTests b/.github/DockerfileBackendTests index 7fda0e025f..dd8452e2cf 100644 --- a/.github/DockerfileBackendTests +++ b/.github/DockerfileBackendTests @@ -42,7 +42,7 @@ RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VER RUN /usr/local/bin/python3 -m pip install pip-tools # Bun -COPY --from=oven/bun:1.2.4 /usr/local/bin/bun /usr/bin/bun +COPY --from=oven/bun:1.2.18 /usr/local/bin/bun /usr/bin/bun ARG TARGETPLATFORM diff --git a/Dockerfile b/Dockerfile index 934ef10148..3815744d1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -194,7 +194,7 @@ COPY --from=builder /windmill/target/release/windmill ${APP}/windmill COPY --from=denoland/deno:2.2.1 --chmod=755 /usr/bin/deno /usr/bin/deno -COPY --from=oven/bun:1.2.4 /usr/local/bin/bun /usr/bin/bun +COPY --from=oven/bun:1.2.18 /usr/local/bin/bun /usr/bin/bun COPY --from=php:8.3.7-cli /usr/local/bin/php /usr/bin/php COPY --from=composer:2.7.6 /usr/bin/composer /usr/bin/composer diff --git a/backend/windmill-worker/loader_builder.bun.js b/backend/windmill-worker/loader_builder.bun.js index dec0e41fed..2bf0b749f2 100644 --- a/backend/windmill-worker/loader_builder.bun.js +++ b/backend/windmill-worker/loader_builder.bun.js @@ -1,9 +1,15 @@ -const bo = await Bun.build({ - entrypoints: ["./main.ts"], - outdir: "./out", - plugins: [p], - external: ["*"], -}); +try { + await Bun.build({ + entrypoints: ["./main.ts"], + outdir: "./out", + plugins: [p], + external: ["*"], + }); +} catch (err) { + console.log(err); + console.log("Failed to build bundle"); + process.exit(1); +} const fs = require("fs/promises"); @@ -12,66 +18,58 @@ const captureVersion = import { semver } from "bun"; -if (!bo.success) { - bo.logs.forEach((l) => console.log(l)); - console.log("Failed to build bundle"); - process.exit(1); -} else { - let content = await fs.readFile("./out/main.js", { encoding: "utf8" }); - const imports = new Bun.Transpiler().scanImports( - content.replaceAll("__require", "require") - ); +let content = await fs.readFile("./out/main.js", { encoding: "utf8" }); +const imports = new Bun.Transpiler().scanImports( + content.replaceAll("__require", "require") +); - const dependencies = {}; - for (const i of imports) { - let [_, name, version] = i.path.match(captureVersion) ?? []; - if (name == undefined) { - throw Error("Unrecognized import: " + i.path); - } - if (name.startsWith("node:")) { - continue; - } - let splitted = name.split("/"); - if (splitted.length > 2) { - name = splitted.slice(0, 2).join("/"); - } - if (version == undefined) { - if (dependencies[name] == undefined) { - dependencies[name] = []; - } - } else { - if (dependencies[name] == undefined) { - dependencies[name] = [version]; - } else if (!dependencies[name].includes(version)) { - dependencies[name].push(version); - } - } +const dependencies = {}; +for (const i of imports) { + let [_, name, version] = i.path.match(captureVersion) ?? []; + if (name == undefined) { + throw Error("Unrecognized import: " + i.path); } - const resolvedDeps = {}; - for (const i in dependencies) { - const versions = dependencies[i]; - resolvedDeps[i] = - versions.length == 0 - ? "latest" - : versions.length == 1 - ? versions[0] - : reduceIntersect(versions, i); + if (name.startsWith("node:")) { + continue; } - await Bun.write( - "./package.json", - JSON.stringify({ dependencies: resolvedDeps }, null, 2) - ); - - function reduceIntersect(versions, name) { - console.log( - `multiple versions detected for ${name}: ${versions.join(", ")}` - ); - const regex = /^(?:\^|~|<|<=|>=|>)+/g; - - const r = versions - .map((x) => [x, x.replace(regex, "")]) - .sort((a, b) => semver.order(a[1], b[1]))[0][0]; - console.log(`resolved to ${r} for ${name}`); - return r; + let splitted = name.split("/"); + if (splitted.length > 2) { + name = splitted.slice(0, 2).join("/"); + } + if (version == undefined) { + if (dependencies[name] == undefined) { + dependencies[name] = []; + } + } else { + if (dependencies[name] == undefined) { + dependencies[name] = [version]; + } else if (!dependencies[name].includes(version)) { + dependencies[name].push(version); + } } } +const resolvedDeps = {}; +for (const i in dependencies) { + const versions = dependencies[i]; + resolvedDeps[i] = + versions.length == 0 + ? "latest" + : versions.length == 1 + ? versions[0] + : reduceIntersect(versions, i); +} +await Bun.write( + "./package.json", + JSON.stringify({ dependencies: resolvedDeps }, null, 2) +); + +function reduceIntersect(versions, name) { + console.log(`multiple versions detected for ${name}: ${versions.join(", ")}`); + const regex = /^(?:\^|~|<|<=|>=|>)+/g; + + const r = versions + .map((x) => [x, x.replace(regex, "")]) + .sort((a, b) => semver.order(a[1], b[1]))[0][0]; + console.log(`resolved to ${r} for ${name}`); + return r; +} diff --git a/backend/windmill-worker/src/bun_executor.rs b/backend/windmill-worker/src/bun_executor.rs index f724f564df..a508f3084c 100644 --- a/backend/windmill-worker/src/bun_executor.rs +++ b/backend/windmill-worker/src/bun_executor.rs @@ -418,17 +418,17 @@ try {{ }} -const bo = await Bun.build({{ - entrypoints: ["{job_dir}/wrapper.mjs"], - outdir: "./", - target: "node", - plugins: [p], - external: fileNames, - minify: true, - }}); - -if (!bo.success) {{ - bo.logs.forEach((l) => console.log(l)); +try {{ + await Bun.build({{ + entrypoints: ["{job_dir}/wrapper.mjs"], + outdir: "./", + target: "node", + plugins: [p], + external: fileNames, + minify: true, + }}); +}} catch(err) {{ + console.log(err); console.log("Failed to build node bundle"); process.exit(1); }} @@ -462,21 +462,21 @@ plugin(p) r#" {} -const bo = await Bun.build({{ - entrypoints: ["{job_dir}/main.ts"], - outdir: "./", - target: "{}", - plugins: [p], - external: ["electron"], - minify: {{ - identifiers: false, - syntax: true, - whitespace: false - }}, - }}); - -if (!bo.success) {{ - bo.logs.forEach((l) => console.log(l)); +try {{ + await Bun.build({{ + entrypoints: ["{job_dir}/main.ts"], + outdir: "./", + target: "{}", + plugins: [p], + external: ["electron"], + minify: {{ + identifiers: false, + syntax: true, + whitespace: false + }}, + }}); +}} catch(err) {{ + console.log(err) console.log("Failed to build node bundle"); process.exit(1); }} diff --git a/docker/DockerfileSlim b/docker/DockerfileSlim index 3be8c6c5b8..ca749b02f0 100644 --- a/docker/DockerfileSlim +++ b/docker/DockerfileSlim @@ -20,7 +20,7 @@ RUN /usr/local/bin/python3 -m pip install pip-tools # Install UV RUN curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.15/uv-installer.sh | sh && mv /root/.local/bin/uv /usr/local/bin/uv -COPY --from=oven/bun:1.2.4 /usr/local/bin/bun /usr/bin/bun +COPY --from=oven/bun:1.2.18 /usr/local/bin/bun /usr/bin/bun # add the docker client to call docker from a worker if enabled COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/ diff --git a/docker/DockerfileSlimEe b/docker/DockerfileSlimEe index f3f1e26cee..4b001f5d10 100644 --- a/docker/DockerfileSlimEe +++ b/docker/DockerfileSlimEe @@ -19,7 +19,7 @@ RUN /usr/local/bin/python3 -m pip install pip-tools # Install UV RUN curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.5.15/uv-installer.sh | sh && mv /root/.local/bin/uv /usr/local/bin/uv -COPY --from=oven/bun:1.2.4 /usr/local/bin/bun /usr/bin/bun +COPY --from=oven/bun:1.2.18 /usr/local/bin/bun /usr/bin/bun # add the docker client to call docker from a worker if enabled COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/