Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ program
.option("-f, --framework <id>", "Build image with a framework pre-installed (e.g. crewai, langgraph)")
.option("--all-frameworks", "Build images for all supported frameworks", false)
.option("--browser", "Build a browser-capable framework image", false)
.action(async (opts: { tag?: string; noCache: boolean; framework?: string; allFrameworks: boolean; browser: boolean }) => {
.action(async (opts: { tag?: string; cache: boolean; framework?: string; allFrameworks: boolean; browser: boolean }) => {
await runBuild(opts);
});

Expand Down
14 changes: 10 additions & 4 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ function resolveSandboxDir(): string {

interface BuildOptions {
tag?: string;
noCache: boolean;
/** False when `--no-cache` is passed (Commander stores negatable flags this way). */
cache?: boolean;
framework?: string;
allFrameworks?: boolean;
browser?: boolean;
}

/** The `docker build` cache flag for the given `cache` option. */
export function noCacheArgs(cache: boolean | undefined): string[] {
return cache === false ? ["--no-cache"] : [];
}

export async function runBuild(opts: BuildOptions): Promise<void> {
await assertDockerAvailable();

Expand Down Expand Up @@ -97,7 +103,7 @@ export async function runBuild(opts: BuildOptions): Promise<void> {
"build",
"--file", dockerfilePath,
"--tag", imageTag,
...(opts.noCache ? ["--no-cache"] : []),
...noCacheArgs(opts.cache),
sandboxDir,
];

Expand Down Expand Up @@ -160,7 +166,7 @@ async function buildFrameworkImage(
"build",
"--file", dockerfilePath,
"--tag", imageTag,
...(opts.noCache ? ["--no-cache"] : []),
...noCacheArgs(opts.cache),
contextDir,
];

Expand Down Expand Up @@ -204,7 +210,7 @@ async function buildAllFrameworks(
"build",
"--file", dockerfilePath,
"--tag", imageTag,
...(opts.noCache ? ["--no-cache"] : []),
...noCacheArgs(opts.cache),
contextDir,
]);

Expand Down
1 change: 0 additions & 1 deletion src/commands/quickstart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export async function runQuickstart(opts: QuickstartOptions): Promise<void> {

const { runBuild } = await import("./build.js");
await runBuild({
noCache: false,
framework: opts.framework,
browser: opts.browser,
});
Expand Down
8 changes: 8 additions & 0 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { startContainer } from "../docker/runner.js";
import { SILO_NETWORK } from "../docker/templates.js";
import { ensureGatewaySidecar, needsGatewaySidecar } from "../docker/gateway.js";
import { log, printBanner } from "../utils/logger.js";
import { runBuild } from "./build.js";
import {
assertDockerAvailable,
isContainerRunning,
Expand Down Expand Up @@ -104,6 +105,13 @@ export async function runStart(opts: StartOptions): Promise<void> {
}
}

// ── Rebuild image (--rebuild) ───────────────────────────────────────────
// runBuild tags the image exactly as it is resolved below: the configured
// sandbox image, or the framework image for --framework / --browser.
if (opts.rebuild) {
await runBuild({ framework: framework?.id, browser: opts.browser });
}

// ── Resolve image ───────────────────────────────────────────────────────
let image = config.sandbox.image;
if (framework) {
Expand Down
13 changes: 13 additions & 0 deletions tests/commands/build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, it, expect } from "vitest";
import { noCacheArgs } from "../../src/commands/build.js";

describe("noCacheArgs", () => {
it("adds --no-cache when the cache option is false (silo build --no-cache)", () => {
expect(noCacheArgs(false)).toEqual(["--no-cache"]);
});

it("adds nothing when the cache option is true or unset", () => {
expect(noCacheArgs(true)).toEqual([]);
expect(noCacheArgs(undefined)).toEqual([]);
});
});
Loading