diff --git a/docker/frontend.Dockerfile b/docker/frontend.Dockerfile index c663141..d0ce95c 100644 --- a/docker/frontend.Dockerfile +++ b/docker/frontend.Dockerfile @@ -1,8 +1,8 @@ # Runtime only — frontend built externally via pnpm FROM nginx:alpine -# Copy pre-built SPA assets -COPY apps/frontend/dist /usr/share/nginx/html +# Copy pre-built SPA assets (pnpm build outputs to dist/) +COPY dist /usr/share/nginx/html # nginx configuration for SPA RUN echo 'server { \ diff --git a/scripts/build.js b/scripts/build.js index 5d8bd50..09a5660 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -4,7 +4,7 @@ * * Workflow: * 1. cargo build --release --target x86_64-unknown-linux-gnu (compile Rust binaries) - * 2. pnpm build (build frontend SPA) + * 2. pnpm build (build frontend SPA, outputs to dist/) * 3. docker build (copy pre-built artifacts into minimal runtime images) * * Usage: @@ -34,6 +34,7 @@ const targets = args.length > 0 ? args : ALL_SERVICES; const rustTargets = targets.filter(s => RUST_SERVICES.includes(s)); const needsFrontend = targets.includes(FRONTEND_SERVICE); +const rootDir = path.join(__dirname, '..'); console.log(`\n=== Build Configuration ===`); console.log(`Registry: ${REGISTRY}`); @@ -54,7 +55,7 @@ if (rustTargets.length > 0) { }; return `--package ${pkgMap[s]}`; }).join(' ')} -j ${cpus}`, - { stdio: 'inherit', cwd: path.join(__dirname, '..') } + { stdio: 'inherit', cwd: rootDir } ); console.log(` [OK] Rust binaries built`); } catch (error) { @@ -63,19 +64,18 @@ if (rustTargets.length > 0) { } } -// Step 2: Build frontend (requires apps/frontend to exist locally) +// Step 2: Build frontend (frontend source is at repo root) if (needsFrontend) { - const frontendDir = path.join(__dirname, '..', 'apps', 'frontend'); - if (!fs.existsSync(frontendDir)) { - console.error(`\n [FAIL] apps/frontend not found. Please ensure frontend source exists.`); + console.log(`\n==> Step 2: Building frontend`); + if (!fs.existsSync(path.join(rootDir, 'vite.config.ts'))) { + console.error(`\n [FAIL] vite.config.ts not found`); process.exit(1); } - console.log(`\n==> Step 2: Building frontend`); try { - execSync(`corepack enable && corepack prepare pnpm@10 --activate && pnpm install --frozen-lockfile && pnpm build`, { - stdio: 'inherit', - cwd: frontendDir, - }); + execSync( + `corepack enable && corepack prepare pnpm@10 --activate && pnpm install --frozen-lockfile && pnpm build`, + { stdio: 'inherit', cwd: rootDir } + ); console.log(` [OK] Frontend built`); } catch (error) { console.error(` [FAIL] Frontend build failed`); @@ -101,7 +101,7 @@ for (const service of targets) { try { execSync( `docker build -f "${dockerfile}" -t "${image}" .`, - { stdio: 'inherit', cwd: path.join(__dirname, '..') } + { stdio: 'inherit', cwd: rootDir } ); console.log(` [OK] ${image}`); } catch (error) {