This commit is contained in:
a2a-platform
2026-06-11 23:13:20 +00:00
parent 195a793bfa
commit 7aab2dccb9
6 changed files with 88 additions and 9 deletions

View File

@@ -137,10 +137,12 @@
"version": "0.1.0", "version": "0.1.0",
"entrypoint": "agent:Robertseares", "entrypoint": "agent:Robertseares",
"frontend": { "frontend": {
"type": "static-spa", "type": "server-rendered",
"framework": "nextjs",
"path": "frontend", "path": "frontend",
"build": "npm run build", "build": "npm run build",
"dist": "out", "start": "node server.js",
"port": 3000,
"mount": "/", "mount": "/",
"auth": "inherit" "auth": "inherit"
} }

View File

@@ -19,10 +19,11 @@ expose:
# url: DATABASE_URL # url: DATABASE_URL
frontend: frontend:
type: static-spa type: server-rendered
framework: nextjs
path: frontend path: frontend
build: npm run build build: npm run build
dist: out start: node server.js
port: 3000
mount: / mount: /
auth: inherit auth: inherit

View File

@@ -1,6 +1,11 @@
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const nextConfig = { const nextConfig = {
output: "export", output: "standalone",
trailingSlash: true, outputFileTracingRoot: __dirname,
}; };
export default nextConfig; export default nextConfig;

View File

@@ -4,8 +4,8 @@
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {
"dev": "next dev --hostname 0.0.0.0 --port 3000", "dev": "next dev --hostname 0.0.0.0 --port 3000",
"build": "next build", "build": "next build && node prepare-standalone.mjs",
"start": "next start" "start": "node start-standalone.mjs"
}, },
"dependencies": { "dependencies": {
"next": "^15.3.0", "next": "^15.3.0",

View File

@@ -0,0 +1,48 @@
import { cpSync, existsSync, mkdirSync, readdirSync } from "node:fs";
import { join } from "node:path";
const standalone = ".next/standalone";
const staticSource = ".next/static";
const publicSource = "public";
function copyDir(source, target) {
if (!existsSync(source)) {
return;
}
mkdirSync(target, { recursive: true });
cpSync(source, target, { recursive: true });
}
function serverDirs() {
if (!existsSync(standalone)) {
return [];
}
const dirs = [];
if (existsSync(join(standalone, "server.js"))) {
dirs.push(standalone);
}
for (const entry of readdirSync(standalone, { withFileTypes: true })) {
if (!entry.isDirectory()) {
continue;
}
const candidate = join(standalone, entry.name);
if (existsSync(join(candidate, "server.js"))) {
dirs.push(candidate);
}
}
return dirs;
}
for (const dir of serverDirs()) {
copyDir(staticSource, join(dir, ".next/static"));
copyDir(publicSource, join(dir, "public"));
}
if (!existsSync(join(standalone, "server.js"))) {
const nested = serverDirs().find((dir) => dir !== standalone);
if (nested) {
cpSync(nested, standalone, { recursive: true });
copyDir(staticSource, join(standalone, ".next/static"));
copyDir(publicSource, join(standalone, "public"));
}
}

View File

@@ -0,0 +1,23 @@
import { spawnSync } from "node:child_process";
import { existsSync } from "node:fs";
const candidates = [
".next/standalone/server.js",
".next/standalone/frontend/server.js",
];
const server = candidates.find((path) => existsSync(path));
if (!server) {
throw new Error("Next standalone server.js not found; run npm run build first");
}
const result = spawnSync(process.execPath, [server], {
stdio: "inherit",
env: {
...process.env,
HOSTNAME: process.env.HOSTNAME || "127.0.0.1",
PORT: process.env.PORT || "3000",
},
});
process.exit(result.status ?? 1);