- docker-proxy service (tecnativa/docker-socket-proxy) in both compose files; worker uses it via DOCKER_HOST with a dependency-free client. - runtimes table with presets (llama.cpp CPU, vLLM CPU) and custom images; validation of image refs, env, args, devices (/dev/dri, /dev/kfd). - Worker reports Docker/CPU/memory facts and detects its network and models mount; pulls images with progress; image state per runtime. - Settings -> Runtimes page with host card, list, editor, pull/update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
878 B
TypeScript
22 lines
878 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { z } from "zod";
|
|
import { withAuth } from "@/lib/api-auth";
|
|
import { apiError, handleApiError } from "@/lib/api-errors";
|
|
import { createRuntime, getDockerInfo, listRuntimes, RuntimeBody, RuntimeError } from "@/lib/runtimes";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
/** Runtimes plus the Docker facts the worker reported. */
|
|
export const GET = withAuth(async () => NextResponse.json({ runtimes: await listRuntimes(), docker: await getDockerInfo() }));
|
|
|
|
export const POST = withAuth(async (req) => {
|
|
try {
|
|
const body = RuntimeBody.extend({ preset: z.string().optional() }).parse(await req.json());
|
|
return NextResponse.json(await createRuntime(body), { status: 201 });
|
|
} catch (err) {
|
|
if (err instanceof RuntimeError) return apiError(err.status, err.code, err.message);
|
|
return handleApiError(err);
|
|
}
|
|
});
|