From 2a902b713e7e268c136471b291f9516c33d1b359 Mon Sep 17 00:00:00 2001 From: naps62-yolo Date: Mon, 25 May 2026 09:48:57 +0000 Subject: [PATCH] feat(maestro): build web bundle into Docker image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NAP-218. Add a node:20 stage to the registry Dockerfile that runs `pnpm install && pnpm build` against `web/`, then copies the resulting `dist/` into the Rust builder so rust-embed picks it up. Single-binary deploy still — no separate static-asset volume. `.dockerignore` keeps `web/node_modules` and `web/dist` out of the build context (the node stage produces them fresh) while letting the sources through. Co-Authored-By: Claude Opus 4.7 (1M context) --- .dockerignore | 3 ++- Dockerfile | 13 +++++++++++++ crates/maestro-registry/src/web_assets.rs | 3 +-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index ddaa9ab..a0b9c01 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,7 @@ worktrees/ .github/ .claude/ docs/ -web/ +web/node_modules/ +web/dist/ *.md .env* diff --git a/Dockerfile b/Dockerfile index b8b77b0..75f4284 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,22 @@ # set MAESTRO_REGISTRY_BIND_ADDR to), and set MAESTRO_TOKEN as a secret env. # No persistent volume is required when MAESTRO_TOKEN is provided. +# 1. Build the web client bundle. Output lands in /web/dist and is consumed +# by the Rust builder below via `rust-embed`. +FROM node:20-bookworm AS web-builder +WORKDIR /web +RUN corepack enable +COPY web/package.json web/pnpm-lock.yaml* ./ +RUN pnpm install --frozen-lockfile || pnpm install +COPY web/ ./ +RUN pnpm build + +# 2. Build the registry binary. `rust-embed` picks up the bundle that the +# previous stage produced. FROM rust:1-bookworm AS builder WORKDIR /build COPY . . +COPY --from=web-builder /web/dist /build/web/dist RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/build/target \ cargo build --release -p maestro-registry \ diff --git a/crates/maestro-registry/src/web_assets.rs b/crates/maestro-registry/src/web_assets.rs index 478cffe..490e43f 100644 --- a/crates/maestro-registry/src/web_assets.rs +++ b/crates/maestro-registry/src/web_assets.rs @@ -17,8 +17,7 @@ use rust_embed::RustEmbed; #[folder = "../../web/dist/"] struct WebAssets; -const FALLBACK_INDEX: &str = - "maestro\ +const FALLBACK_INDEX: &str = "maestro\

maestro registry

\

Web bundle not built. Run pnpm --dir web install \ then pnpm --dir web build, then rebuild the registry.

";