Files
opencode/packages/containers/script/build.ts
Dax Raad 849f488744 ci
2026-01-29 23:15:12 -05:00

42 lines
1.5 KiB
TypeScript

#!/usr/bin/env bun
import { $ } from "bun"
import path from "path"
import { fileURLToPath } from "url"
const rootDir = fileURLToPath(new URL("../../..", import.meta.url))
process.chdir(rootDir)
const reg = process.env.REGISTRY ?? "ghcr.io/anomalyco"
const tag = process.env.TAG ?? "24.04"
const push = process.argv.includes("--push") || process.env.PUSH === "1"
const root = path.join(rootDir, "package.json")
const pkg = await Bun.file(root).json()
const manager = pkg.packageManager ?? ""
const bun = manager.startsWith("bun@") ? manager.slice(4) : ""
if (!bun) throw new Error("packageManager must be bun@<version>")
const images = ["base", "bun-node", "rust", "tauri-linux", "publish"]
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 (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 (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) {
await $`docker push ${image}`
}
}