From cd664a189b7c1de5232b58c180fca72b86adada6 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 29 Jan 2026 23:17:57 -0500 Subject: ci --- packages/containers/script/build.ts | 50 +++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'packages/containers/script') diff --git a/packages/containers/script/build.ts b/packages/containers/script/build.ts index ff259f2ab..6b880e7a5 100644 --- a/packages/containers/script/build.ts +++ b/packages/containers/script/build.ts @@ -19,23 +19,59 @@ if (!bun) throw new Error("packageManager must be bun@") const images = ["base", "bun-node", "rust", "tauri-linux", "publish"] +const setup = async () => { + if (!push) return + const list = await $`docker buildx ls`.text() + if (list.includes("opencode")) { + await $`docker buildx use opencode` + return + } + await $`docker buildx create --name opencode --use` +} + +await setup() + +const platform = "linux/amd64,linux/arm64" + for (const name of images) { const image = `${reg}/build/${name}:${tag}` const file = `packages/containers/${name}/Dockerfile` if (name === "base") { - console.log(`docker build -f ${file} -t ${image} .`) - await $`docker build -f ${file} -t ${image} .` + if (push) { + console.log(`docker buildx build --platform ${platform} -f ${file} -t ${image} --push .`) + await $`docker buildx build --platform ${platform} -f ${file} -t ${image} --push .` + } + if (!push) { + console.log(`docker build -f ${file} -t ${image} .`) + await $`docker build -f ${file} -t ${image} .` + } } if (name === "bun-node") { - console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .`) - await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .` + if (push) { + console.log( + `docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} --push .`, + ) + await $`docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} --push .` + } + if (!push) { + console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .`) + await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .` + } } if (name !== "base" && name !== "bun-node") { - console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .`) - await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .` + if (push) { + console.log( + `docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --push .`, + ) + await $`docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --push .` + } + if (!push) { + console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .`) + await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .` + } } if (push) { - await $`docker push ${image}` + console.log(`pushed ${image}`) } } -- cgit v1.2.3