Something went wrong. Try again.
A self-hosted household ledger.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273// Build (and optionally push) the Quantum container image, stamping OCI version// metadata from ChronVer + git so the registry shows real project info.//// deno task image # build atcr.io/graham.systems/quantum:<version> + :latest// deno task image --push # build, then `docker push` both tags// deno task image -- --no-cache # extra flags after `--` go to docker buildimport { currentVersion } from "./version.ts";
const IMAGE = "atcr.io/graham.systems/quantum";
async function tryGit(...args: string[]): Promise<string> { try { const { code, stdout } = await new Deno.Command("git", { args, stdout: "piped", stderr: "null", }).output(); return code === 0 ? new TextDecoder().decode(stdout).trim() : ""; } catch { return ""; }}
async function run(cmd: string, args: string[]): Promise<number> { const { code } = await new Deno.Command(cmd, { args, stdout: "inherit", stderr: "inherit", }).output(); return code;}
const version = await currentVersion();const revision = await tryGit("rev-parse", "--short", "HEAD");const created = new Date().toISOString();
const push = Deno.args.includes("--push");// Anything after a literal `--` is forwarded verbatim to `docker build`.const passthroughAt = Deno.args.indexOf("--");const extra = passthroughAt === -1 ? [] : Deno.args.slice(passthroughAt + 1);
const tags = [`${IMAGE}:${version}`, `${IMAGE}:latest`];
console.log( `Building ${IMAGE}:${version} (revision ${ revision || "unknown" }, created ${created})`,);
const buildArgs = [ "build", "--build-arg", `VERSION=${version}`, "--build-arg", `CREATED=${created}`, "--build-arg", `REVISION=${revision}`, ...tags.flatMap((t) => ["-t", t]), ...extra, ".",];
let code = await run("docker", buildArgs);if (code === 0 && push) { for (const t of tags) { console.log(`Pushing ${t}`); code = await run("docker", ["push", t]); if (code !== 0) break; }}
Deno.exit(code);