Files
Kaname/next.config.ts
T
Claude 67cd0c945a
Release / release (push) Failing after 10s
Docker: standalone server, bundled worker, no caches in the image
The runtime stage copied the whole production node_modules (495 MB, with
shadcn's CLI tree, the SWC compiler and sharp) and all of .next (163 MB, 119 MB
of it Turbopack's build cache). The image is now 427 MB instead of 1.04 GB:

- Next.js standalone output (NEXT_OUTPUT=standalone, set by the Dockerfile; a
  local `next build`/`next start` is unchanged): server.js with only the traced
  node_modules (39 MB). images.unoptimized (nothing uses next/image) keeps sharp
  and libvips out of the server's trace; /_next/image answers 404.
- build:worker bundles drizzle-orm, zod and ulid into dist/*.mjs and keeps only
  @libsql/client and libsql external; the standalone node_modules has both.
- npm's cache and .next/cache are BuildKit cache mounts: reused by the next
  build on the same machine (Next build 30 s -> 12 s after a code change), never
  in a layer.
- Release archives (BetterBench, both L80 tarballs) are fetched in their own
  stage; only the L80 binary is copied, BetterBench is installed from a bind
  mount.
- shadcn and tw-animate-css (CSS imports, build time only) move to
  devDependencies; package-lock.json regenerated with npm 11 (the image's npm).

Verified by building the image and running web, worker and sandbox from it:
pages and /api/live answer, the worker migrates, takes the lease and finds hf,
BetterBench and L80, all three healthchecks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
2026-11-01 21:23:51 +00:00

17 lines
928 B
TypeScript

import type { NextConfig } from "next";
const nextConfig: NextConfig = {
// Native SQLite driver: load from node_modules at runtime instead of bundling.
serverExternalPackages: ["@libsql/client", "libsql"],
// The Docker image runs the standalone server: only the files the server needs instead of all of
// node_modules (see Dockerfile). Local `next build` / `next start` stay as they are.
output: process.env.NEXT_OUTPUT === "standalone" ? "standalone" : undefined,
// Nothing uses next/image (model cards show the Hub's images as they are). With the optimizer off
// (/_next/image answers 404), sharp and its native libvips (28 MB) stay out of the standalone
// output; "next-server" is the key Next applies to its own server's trace.
images: { unoptimized: true },
outputFileTracingExcludes: { "next-server": ["**/node_modules/sharp/**/*", "**/node_modules/@img/**/*"] },
};
export default nextConfig;