mirror of
https://github.com/Dasemu/remote-mcp-manager.git
synced 2026-11-26 15:26:27 +00:00
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:
1 parent
309e6aedc3
commit
b8f5d8253f
33 files changed
+3502
-42
No files matched your search
@@ -0,0 +1,60 @@
|
||||
export interface Installation {
|
||||
id: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
repoUrl: string;
|
||||
gitRef: string | null;
|
||||
status: "draft" | "cloning" | "building" | "built" | "starting" | "running" | "stopped" | "error";
|
||||
statusDetail: string | null;
|
||||
imageTag: string | null;
|
||||
containerName: string;
|
||||
internalPort: number;
|
||||
httpPath: string;
|
||||
portEnvVar: string;
|
||||
hostEnvVar: string;
|
||||
env: Record<string, string>;
|
||||
bearerToken: string | null;
|
||||
publicUrl: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const res = await fetch(path, {
|
||||
...init,
|
||||
credentials: "include",
|
||||
headers: { "Content-Type": "application/json", ...(init?.headers ?? {}) },
|
||||
});
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({ error: res.statusText }));
|
||||
throw new Error(body.error ?? `request failed with ${res.status}`);
|
||||
}
|
||||
if (res.status === 204) return undefined as T;
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export const api = {
|
||||
session: () => request<{ authenticated: boolean }>("/api/auth/session"),
|
||||
login: (password: string) => request<{ ok: true }>("/api/auth/login", { method: "POST", body: JSON.stringify({ password }) }),
|
||||
logout: () => request<{ ok: true }>("/api/auth/logout", { method: "POST" }),
|
||||
|
||||
listInstallations: () => request<Installation[]>("/api/installations"),
|
||||
getInstallation: (id: string) => request<Installation>(`/api/installations/${id}`),
|
||||
createInstallation: (input: { name: string; repoUrl: string; gitRef?: string }) =>
|
||||
request<{ installation: Installation; detectedEnvKeys: string[] }>("/api/installations", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(input),
|
||||
}),
|
||||
configureInstallation: (
|
||||
id: string,
|
||||
patch: { env?: Record<string, string>; portEnvVar?: string; hostEnvVar?: string; httpPath?: string },
|
||||
) => request<Installation>(`/api/installations/${id}/config`, { method: "PATCH", body: JSON.stringify(patch) }),
|
||||
build: (id: string) => request<Installation>(`/api/installations/${id}/build`, { method: "POST" }),
|
||||
deploy: (id: string) => request<Installation>(`/api/installations/${id}/deploy`, { method: "POST" }),
|
||||
redeploy: (id: string, rebuild: boolean) =>
|
||||
request<Installation>(`/api/installations/${id}/redeploy`, { method: "POST", body: JSON.stringify({ rebuild }) }),
|
||||
regenerateToken: (id: string) =>
|
||||
request<{ bearerToken: string }>(`/api/installations/${id}/regenerate-token`, { method: "POST" }),
|
||||
remove: (id: string) => request<void>(`/api/installations/${id}`, { method: "DELETE" }),
|
||||
logs: (id: string) => request<{ log: string }>(`/api/installations/${id}/logs`),
|
||||
};
|
||||
Reference in new issue
Block a user