feat: SQLite-backed installations, REST API, admin auth and web UI

Replaces the slice-2 hardcoded installation with a full install/deploy
pipeline:

- SQLite persistence (better-sqlite3) with a single `installations`
  table and a draft -> cloning -> building -> built -> starting ->
  running/error/stopped state machine; env vars and bearer tokens are
  encrypted at rest (AES-256-GCM, key derived from MASTER_KEY).
- Build/run orchestration: git clone (+ .env.example key detection),
  `nixpacks build` as a logged subprocess, dockerode container
  run/stop with forced host/port env vars and a TCP-connect health
  check before flipping an installation to "running".
- REST API (installations CRUD, build/deploy/redeploy, logs, token
  regeneration) behind single-operator session-cookie auth with a
  basic login lockout.
- Vite+React admin SPA: login, installation list, install wizard, and
  a detail page to configure env vars, trigger build/deploy/redeploy,
  view the build log, and copy the authenticated /mcp/<slug> URL.
- Dockerfile (multi-stage, pulls in nixpacks + the Docker CLI) and
  docker-compose.yml for production deployment.

Validated end-to-end against a real cloned repo: draft creation with
env-key detection, build, the error path on a failed health check, and
delete, all through the live API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5 committed 2026-10-08 01:42:06 +02:00
1 parent 309e6aedc3
commit b8f5d8253f
33 files changed
+3502 -42

No files matched your search

+36
View File
@@ -1,13 +1,49 @@
import path from "node:path";
import express from "express";
import session from "express-session";
import { config } from "./config/env.js";
import "./db/index.js";
import { handleMcpProxyRequest } from "./proxy/mcpProxy.js";
import { authRouter } from "./api/auth.js";
import { installationsRouter } from "./api/installations.js";
import { requireAuth } from "./middleware/requireAuth.js";
if (!config.sessionSecret) {
throw new Error("SESSION_SECRET env var must be set");
}
const app = express();
app.set("trust proxy", 1);
app.use(express.json());
app.use(
session({
secret: config.sessionSecret,
resave: false,
saveUninitialized: false,
cookie: {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
maxAge: 1000 * 60 * 60 * 12,
},
}),
);
app.get("/health", (_req, res) => res.json({ ok: true }));
// Bearer-token-gated MCP reverse proxy, public (auth handled per-installation).
app.all("/mcp/:slug", handleMcpProxyRequest);
app.use("/api/auth", authRouter);
app.use("/api/installations", requireAuth, installationsRouter);
const webDist = path.resolve(import.meta.dirname, "../../web/dist");
app.use(express.static(webDist));
app.get(/^\/(?!api|mcp|health).*/, (_req, res) => {
res.sendFile(path.join(webDist, "index.html"), (err) => {
if (err) res.status(404).end();
});
});
app.listen(config.port, () => {
console.log(`remote-mcp-manager listening on http://localhost:${config.port}`);
});