feat: embed frontend into backend server with full-stack build pipeline (RCA-20)
The backend now serves the Vue admin UI as static files with SPA fallback, eliminating the need for a separate web server. Dockerfile builds both frontend and backend in a multi-stage pipeline. Added build:web and build:all scripts, updated CI to verify frontend builds, and fixed vitest config to exclude Playwright tests. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
22
src/cli.ts
22
src/cli.ts
@@ -1,3 +1,5 @@
|
||||
import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
import { RelayServer } from "./relay/index.js";
|
||||
import { loadDbConfig, createStores } from "./relay/db/index.js";
|
||||
|
||||
@@ -16,10 +18,28 @@ async function main() {
|
||||
console.log("Configure a database during setup to enable persistent storage.");
|
||||
}
|
||||
|
||||
const server = new RelayServer({ port, host, stores });
|
||||
// Resolve frontend public directory: check ./public (production) then ../web/dist (development)
|
||||
let publicDir: string | undefined;
|
||||
const candidates = [
|
||||
path.resolve("public"),
|
||||
path.resolve(__dirname, "..", "web", "dist"),
|
||||
];
|
||||
for (const dir of candidates) {
|
||||
if (fs.existsSync(path.join(dir, "index.html"))) {
|
||||
publicDir = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const server = new RelayServer({ port, host, stores, publicDir });
|
||||
|
||||
await server.start();
|
||||
console.log(`CookieBridge relay server listening on ${host}:${port}`);
|
||||
if (publicDir) {
|
||||
console.log(`Serving admin UI from ${publicDir}`);
|
||||
} else {
|
||||
console.log("No frontend build found — admin UI not available. Run: npm run build:web");
|
||||
}
|
||||
|
||||
process.on("SIGINT", async () => {
|
||||
console.log("\nShutting down...");
|
||||
|
||||
Reference in New Issue
Block a user