[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M758D4G5K4MYHC0M2C511CYM":3,"skill-same:01M758D4G5K4MYHC0M2C511CYM":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M758D4G5K4MYHC0M2C511CYM","nextjs-docker-multistage",null,"Next.js Docker multi-stage builds with standalone output — minimal runtime images, no node_modules in production","lukemcqueen\u002Fsteadfaste-fleet","lukemcqueen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F405240?v=4","01M757MHPAGRXTJAT46SKZP98R","Luke McQueen","01M757MHPZ573KP8DT9GB8SBQ7",4,"MIT","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fnextjs-docker-multistage\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: nextjs-docker-multistage\ndescription: \"Next.js Docker multi-stage builds with standalone output — minimal runtime images, no node_modules in production\"\nversion: 1.0.0\nauthor: Steadfaste Fleet\nmetadata:\n  tags: [nextjs, docker, multi-stage, standalone, best-practices]\n---\n\n# Next.js Docker Multi-Stage Build (Standalone Output)\n\n## When to Use\n\n- Creating or updating a Dockerfile for a standalone Next.js app (not a monorepo package)\n- Reviewing a Dockerfile that copies `node_modules` into the runtime image\n- Debugging large image sizes (>500MB) for a Next.js production container\n- **For pnpm workspace monorepo builds**, use `pnpm-monorepo-docker` instead (standalone output path differs)\n\n## The Problem\n\nNaive Dockerfiles copy `node_modules` directly into the final image:\n\n```dockerfile\nFROM node:22-alpine AS build\nWORKDIR \u002Fapp\nCOPY . .\nRUN npm install && npm run build\n\nFROM node:22-alpine\nWORKDIR \u002Fapp\nCOPY --from=build \u002Fapp\u002Fnode_modules .\u002Fnode_modules   # ← bloated, fragile\nCOPY --from=build \u002Fapp\u002F.next .\u002F.next\nCMD [\"npm\", \"start\"]\n```\n\nIssues:\n- **Image bloat** — `node_modules` includes dev deps (TypeScript, ESLint, vitest, etc.)\n- **OS-native binaries** — `sharp`, `@swc\u002Fcore` are built for the host arch, not the container's target arch\n- **Security surface** — every transitive dep is an extra CVE vector\n- **Startup overhead** — Node.js has to resolve modules from thousands of files\n\n## The Fix: Standalone Output\n\nNext.js `output: 'standalone'` traces all runtime dependencies into `.next\u002Fstandalone\u002F` — producing a self-contained bundle with only the code actually needed at runtime.\n\n**Two approaches for the Dockerfile build stage:**\n\n- **Multi-stage `deps` + `build` + `runtime`** (below) — uses `pnpm fetch` to populate the pnpm store in a deps layer, then `pnpm install --offline` to rebuild symlinks in build. Good for large monorepos where lockfile rarely changes. See `pnpm-monorepo-docker` §8 for symlink caveats.\n- **Single-stage `build` + `runtime`** — simpler, runs `pnpm install --frozen-lockfile --prod` directly. Layer caching still works because `package.json` and `pnpm-lock.yaml` change less often than source. Preferred for standalone apps where the extra `deps` stage adds complexity. See the Alternative box at the end of Step 2.\n\n**`--prod` vs `--no-dev`:** `--no-dev` is NOT a valid pnpm flag. It is silently ignored, causing ALL devDependencies to be installed. But `--prod` strips devDeps, which may be needed for the build (tailwindcss, postcss, typescript). **Strategy:**\n- **Multi-stage builds** (with a `deps` stage): Omit `--prod` in the build stage. Use `pnpm install --offline --frozen-lockfile` so devDeps are available for `next build`. The standalone runtime excludes them.\n- **Single-stage builds**: Use `pnpm install --frozen-lockfile --prod` but move build tools (tailwindcss, postcss, typescript) from devDependencies to dependencies in package.json.\n\n### Step 1: Enable standalone in next.config\n\n```ts\n\u002F\u002F next.config.ts\nconst nextConfig: NextConfig = {\n  output: 'standalone',\n  \u002F\u002F ... other config\n};\n```\n\n### Step 2: Multi-stage Dockerfile\n\n```dockerfile\n# ── Deps: install all dependencies ──\nFROM node:22-alpine AS deps\nRUN corepack enable && corepack prepare pnpm@10 --activate\nWORKDIR \u002Fapp\nCOPY pnpm-lock.yaml package.json .\u002F\nRUN pnpm fetch --frozen-lockfile\n\n# ── Build: compile the app ──\nFROM node:22-alpine AS build\nRUN corepack enable && corepack prepare pnpm@10 --activate\nWORKDIR \u002Fapp\nCOPY --from=deps \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY pnpm-lock.yaml package.json .\u002F\n# NOTE: No --prod flag — devDeps (tailwindcss, postcss, typescript) are\n# needed for next build. Standalone output traces only runtime deps,\n# so devDeps do not leak into the runtime image.\nRUN pnpm install --offline --frozen-lockfile\nCOPY . .\nRUN pnpm build\n\n# ── Runtime: standalone only ──\nFROM node:22-alpine AS runtime\nRUN addgroup --system --gid 1001 nodejs \\\n    && adduser --system --uid 1001 nextjs\nWORKDIR \u002Fapp\n\n# Copy standalone bundle (self-contained, no node_modules needed)\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstandalone .\u002F\n# Copy static assets (served by Next.js directly)\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\n# Copy public assets\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002Fpublic .\u002Fpublic\n\nUSER nextjs\nEXPOSE 3000\nENV PORT=3000\nCMD [\"node\", \"server.js\"]\n```\n\n**No ARG NEXT_PUBLIC_API_URL needed** when using Next.js rewrites. See \"Rewrites Alternative\" below.\n\nThe runtime image contains ONLY:\n- `server.js` + traced runtime code (~5-20MB)\n- `.next\u002Fstatic\u002F` (compiled chunks, ~200KB-2MB)\n- `public\u002F` (static assets)\n- No `node_modules\u002F`, no dev tools, no source files\n\n**Alternative — single-stage build (simpler, no `deps` stage):**\n\n```dockerfile\nFROM node:22-alpine AS build\nRUN corepack enable && corepack prepare pnpm@10 --activate\nWORKDIR \u002Fapp\n\n# Layer 1: deps (cached until package.json or lockfile changes)\nCOPY package.json pnpm-lock.yaml .npmrc .\u002F\nRUN pnpm install --frozen-lockfile --prod\n\n# Layer 2: source (invalidates on any file change)\nCOPY . .\nRUN pnpm build\n\nFROM node:22-alpine AS runtime\nRUN addgroup --system --gid 1001 nodejs \\\n    && adduser --system --uid 1001 nextjs\nWORKDIR \u002Fapp\n\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstandalone .\u002F\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002Fpublic .\u002Fpublic\n\nUSER nextjs\nEXPOSE 3000\nENV PORT=3000\nCMD [\"node\", \"server.js\"]\n```\n\nDocker layer caching still separates deps from source: Layer 1 caches on `package.json`\u002F`lockfile` content; Layer 2 on remaining source. This is simpler than the `deps` + `build` two-stage approach and avoids `pnpm fetch` symlink issues entirely.\n\n### Step 3: Build the image\n\n```bash\ndocker build --build-arg NEXT_PUBLIC_API_URL=http:\u002F\u002Fapi:8000 -t myapp-web .\n```\n\n## Alternative: Eliminate ARG with Next.js Rewrites\n\nInstead of baking `NEXT_PUBLIC_API_URL` into the client bundle at build time (which requires a build arg and causes cross-origin API calls), use Next.js rewrites to proxy API requests through the same origin:\n\n### Step A: API_BASE uses relative path\n\n```ts\n\u002F\u002F lib\u002Fapi\u002Findex.ts\nexport const API_BASE = process.env.NEXT_PUBLIC_API_URL || \"\u002Fapi\";\n```\n\nWhen `NEXT_PUBLIC_API_URL` is unset (no build arg), the client calls `\u002Fapi\u002Fauth\u002Flogin` (same-origin). When set (legacy config), it still works.\n\n### Step B: Add rewrites in next.config.ts\n\n```ts\n\u002F\u002F next.config.ts\nasync rewrites() {\n  return [\n    {\n      source: \"\u002Fapi\u002F:path*\",\n      destination: `${process.env.API_INTERNAL_URL || \"http:\u002F\u002Flocalhost:13202\"}\u002Fapi\u002F:path*`,\n    },\n  ];\n}\n```\n\nAt runtime, `API_INTERNAL_URL` tells the Next.js server where to forward API requests. In Docker Compose, set it to the internal service hostname.\n\n### Step C: Docker Compose sets API_INTERNAL_URL (not NEXT_PUBLIC_API_URL)\n\n```yaml\n# docker-compose.yml\nweb:\n  environment:\n    API_INTERNAL_URL: http:\u002F\u002Fapi:8000   # Docker internal DNS\n```\n\n### Step D: Add API_INTERNAL_URL as a Dockerfile build arg\n\n**CRITICAL: `next.config.ts` `async rewrites()` is evaluated at BUILD time, not runtime.** The rewrite destination is baked into the `required-server-files.json` during `next build`.\n\nThis means `process.env.API_INTERNAL_URL` in `next.config.ts` reads the build-time value, not the runtime container environment. You MUST pass it as a Dockerfile `ARG`:\n\n```dockerfile\nFROM node:22-alpine AS build\nARG API_INTERNAL_URL=http:\u002F\u002Fapi:8000\nENV API_INTERNAL_URL=$API_INTERNAL_URL\n```\n\nFor docker-compose, add it to the web service's `environment:` — it passes through to the build context:\n\n```yaml\nweb:\n  environment:\n    API_INTERNAL_URL: ${API_INTERNAL_URL:-http:\u002F\u002Fapi:8000}\n```\n\nIf the ARG is missing, the rewrite destination falls back to `\"http:\u002F\u002Flocalhost:13202\"` — which only works when the web server is on the host network, NOT inside Docker's internal network.\n\n### Combined example (Dockerfile + next.config + compose):\n\n**`next.config.ts`**:\n```ts\nasync rewrites() {\n  return [\n    {\n      source: \"\u002Fapi\u002F:path*\",\n      destination: `${process.env.API_INTERNAL_URL || \"http:\u002F\u002Flocalhost:13202\"}\u002Fapi\u002F:path*`,\n    },\n  ];\n}\n```\n\n**`Dockerfile`**:\n```dockerfile\nARG API_INTERNAL_URL=http:\u002F\u002Fapi:8000\nENV API_INTERNAL_URL=$API_INTERNAL_URL\n```\n\n**`docker-compose.yml`**:\n```yaml\nweb:\n  environment:\n    API_INTERNAL_URL: ${API_INTERNAL_URL:-http:\u002F\u002Fapi:8000}\n```\n\n### Benefits\n\n- **No CORS** — all requests are same-origin through the web server\n- **No build-time coupling** — the Docker image is independent of the API URL\n- **nginx compatibility** — if nginx is in front, it catches `\u002Fapi\u002F` before Next.js rewrites fire (no double-proxying)\n- **Cleaner separation** — build config (what the image needs at build) vs runtime config (where the backend lives)\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `Cannot find module 'next'` at runtime | Standalone not enabled, or COPY path wrong | Verify `output: 'standalone'` in next.config; check COPY destination |\n| `Error: ENOENT: no such file or directory` | Monorepo: standalone output is nested | Copy from `.next\u002Fstandalone\u002Fapps\u002Fweb\u002F` not `.next\u002Fstandalone\u002F` |\n| Image still >300MB | Static assets or public\u002F are too large | Audit `public\u002F` for binary files; use CDN for large assets |\n| New page routes return 404 in Docker, but host `next build` lists them | Standalone tracer's `.next\u002Fserver\u002F` directory (contains new route trees) is NOT copied into the runtime image | The multi-stage Dockerfile's `COPY --from=build \u002Fapp\u002F.next\u002Fstandalone .\u002F.next` copies the standalone bundle, and `COPY --from=build \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic` copies static chunks. But the tracer's **`.next\u002Fserver\u002F`** directory — which contains the server chunks for newly added route directories (admin\u002F, shares\u002F, publisher\u002Fsubmit\u002F, etc.) — is not copied unless explicitly added. **Fix:** Add `COPY --from=build \u002Fapp\u002F.next\u002Fserver .\u002F.next\u002Fserver` after the standalone and static copies in the runtime stage. This is deterministic — `--no-cache` rebuild alone does NOT fix it because the tracer output is correct in the build stage; the missing step is the COPY directive. |\n| `pnpm build` fails with `No projects matched` | Wrong filter name in monorepo | Check exact package name from package.json |\n| `sharp` fails to load | Native binary mismatch | Ensure native deps are built in the same arch as runtime (Alpine uses musl) |\n| `node: not found` | Alpine image mismatch | Use `node:22-alpine` consistently across all stages |\n| `COPY public .\u002Fpublic fails` | No `public\u002F` directory exists | Remove the COPY line or create the directory. Many Next.js apps have no static public assets. |\n| `pnpm approve-builds` hangs at build time | `approve-builds` is interactive (requires TTY); Docker build has no TTY | Never call `pnpm approve-builds` in a Dockerfile. Instead, configure `only-built-dependencies[]` in `.npmrc` at the project root. |\n| `Node.js 18+ module not found` at runtime with standalone output | Standalone tracing via `@vercel\u002Fnft` incorrectly marks modules as not used | Set `experimental.outputFileTracingIncludes` in `next.config.ts` to force-include missing modules |\n| **`.dockerignore` excludes root `node_modules\u002F` but NOT nested ones — 489MB build context** | `.dockerignore` pattern `node_modules\u002F` only matches root-level. Nested dirs like `web\u002Fnode_modules\u002F` (352MB) are still sent to the Docker daemon. Context transfer stalls at 30+ seconds; build may time out. | Use `**\u002Fnode_modules\u002F` to exclude ALL nested `node_modules` dirs. Verify with `docker buildx build --progress=plain` — context transfer should be \u003C5MB for a Next.js project. |\n| **Docker build hangs after `docker system prune` (cold cache)** | `pnpm install` re-downloads 46+ packages, then `next build` compiles from scratch. | **Fallback:** Build standalone locally, then create a minimal Docker image. |\n| **Tailwind CSS not applied** | `postcss.config.ts` is silently ignored by Next.js 15. Must be `.mjs` or `.js`. CSS contains raw @tailwind directives, no utility classes. | Rename to `postcss.config.mjs`, delete old `.ts`. |\n| **pnpm install --prod strips tailwindcss** | If tailwindcss, postcss, autoprefixer are in devDependencies, --prod skips them. | Move to dependencies in package.json, update lockfile. |\n\n### Next.js 16 TypeScript Strictness — Build-Only Failures\n\n> **Build caching reference:** See `references\u002Fdocker-build-caching.md` for cache mount patterns (`.next\u002Fcache`, pnpm store), the `--no-dev` → `--prod` fix, and the pre-test rebuild ritual.\n\nNext.js 16's Turbopack compiler is stricter about JSX types than v15. These errors may not appear in `tsc` or local dev but will fail `next build` (and therefore Docker builds):\n\n| Error | Pattern | Fix |\n|-------|---------|-----|\n| `Type 'unknown' is not assignable to type 'ReactNode'` | `{state.data && \u003CComponent \u002F>}` where `data: unknown \\| null` | Use `{!!state.data && \u003CComponent \u002F>}` — the `!!` coerces `unknown` to `boolean` which is valid JSX |\n| `Property 'defaultOpen' does not exist on type '...HTMLDetailsElement...'` | `\u003Cdetails defaultOpen={bool}>` — React 19 added `defaultOpen` but TS types may not include it yet | Use `open={bool}` instead (controlled), or add `@ts-expect-error` |\n| `Inferred workspace root may not be correct` | pnpm monorepo + Turbopack can't auto-detect workspace root in Docker | Set `outputFileTracingRoot: path.resolve(__dirname, \"..\u002F..\u002F\")` at the **top level** of `next.config.ts` (NOT under `experimental`). Also add `transpilePackages: [\"\u003Cpackage-name>\"]` |\n| `Object literal may only specify known properties, but 'outputFileTracingRoot' does not exist in type 'NextConfig'` | LSP thinks it belongs under `experimental` — but the Zod schema validates it at top level | Ignore the LSP diagnostic; the compiler accepts it. If it doesn't, wrap in `experimental: { outputFileTracingRoot: ... }` |\n\n**Verification after build fix:**\n```bash\n# Run build locally first (fast iteration)\ncd apps\u002Fweb && pnpm build 2>&1 | tail -5\n\n# Then rebuild Docker\ndocker compose build --no-cache web\n\n# Verify routes in container\ndocker compose exec web find \u002Fapp\u002Fapps\u002Fweb\u002F.next\u002Fserver\u002Fapp -name \"page.js\" 2>\u002Fdev\u002Fnull | sort | head -30\n```\n\n## Official Vercel Patterns\n\nThe [official Next.js Docker example](https:\u002F\u002Fgithub.com\u002Fvercel\u002Fnext.js\u002Ftree\u002Fcanary\u002Fexamples\u002Fwith-docker) provides additional production patterns.\n\n### ARG NODE_VERSION for Easier Maintenance\n\nParameterize the Node.js version so it can be updated in one place:\n\n```dockerfile\nARG NODE_VERSION=24.13.0-slim\n\nFROM node:${NODE_VERSION} AS dependencies\nWORKDIR \u002Fapp\nCOPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* .\u002F\nRUN --mount=type=cache,target=\u002Froot\u002F.npm \\\n    --mount=type=cache,target=\u002Fusr\u002Flocal\u002Fshare\u002F.cache\u002Fyarn \\\n    --mount=type=cache,target=\u002Froot\u002F.local\u002Fshare\u002Fpnpm\u002Fstore \\\n    if [ -f package-lock.json ]; then \\\n      npm ci --no-audit --no-fund; \\\n    elif [ -f yarn.lock ]; then \\\n      corepack enable yarn && yarn install --frozen-lockfile --production=false; \\\n    elif [ -f pnpm-lock.yaml ]; then \\\n      corepack enable pnpm && pnpm install --frozen-lockfile; \\\n    fi\n\nFROM node:${NODE_VERSION} AS builder\nWORKDIR \u002Fapp\nCOPY --from=dependencies \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nRUN if [ -f package-lock.json ]; then \\\n      npm run build; \\\n    elif [ -f yarn.lock ]; then \\\n      corepack enable yarn && yarn build; \\\n    elif [ -f pnpm-lock.yaml ]; then \\\n      corepack enable pnpm && pnpm build; \\\n    fi\n\nFROM node:${NODE_VERSION} AS runner\nWORKDIR \u002Fapp\nENV NODE_ENV=production\nENV PORT=3000\nENV HOSTNAME=\"0.0.0.0\"\nCOPY --from=builder --chown=node:node \u002Fapp\u002Fpublic .\u002Fpublic\nRUN mkdir .next && chown node:node .next\nCOPY --from=builder --chown=node:node \u002Fapp\u002F.next\u002Fstandalone .\u002F\nCOPY --from=builder --chown=node:node \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\nUSER node\nEXPOSE 3000\nCMD [\"node\", \"server.js\"]\n```\n\nThe `ARG` pattern supports npm, yarn, AND pnpm in a single Dockerfile — useful when the project's package manager could vary.\n\n### slim vs alpine\n\n| Base | Size | Libc | Compatibility |\n|------|------|------|---------------|\n| `slim` (glibc) | ~226MB | glibc | Best npm package compatibility |\n| `alpine` (musl) | ~126MB | musl | May break native deps (sharp, @swc\u002Fcore) |\n\n**Use slim when:** compatibility matters more than 100MB savings. Most production deployments should use slim.  \n**Use alpine when:** image size is critical AND you've verified all native dependencies work with musl.\n\n### Bun Runtime Alternative\n\nFor projects using Bun instead of Node.js:\n\n```dockerfile\nFROM oven\u002Fbun:1 AS dependencies\nWORKDIR \u002Fapp\nCOPY package.json bun.lock* .\u002F\nRUN --mount=type=cache,target=\u002Froot\u002F.bun\u002Finstall\u002Fcache \\\n    bun install --no-save --frozen-lockfile\n\nFROM oven\u002Fbun:1 AS builder\nWORKDIR \u002Fapp\nCOPY --from=dependencies \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nENV NODE_ENV=production\nRUN bun run build\n\nFROM oven\u002Fbun:1 AS runner\nWORKDIR \u002Fapp\nENV NODE_ENV=production PORT=3000 HOSTNAME=\"0.0.0.0\"\nCOPY --from=builder --chown=bun:bun \u002Fapp\u002Fpublic .\u002Fpublic\nRUN mkdir .next && chown bun:bun .next\nCOPY --from=builder --chown=bun:bun \u002Fapp\u002F.next\u002Fstandalone .\u002F\nCOPY --from=builder --chown=bun:bun \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\nUSER bun\nEXPOSE 3000\nCMD [\"bun\", \"server.js\"]\n```\n\n### Production .dockerignore\n\nThe official example includes AI\u002FML metadata in `.dockerignore` — exclude `.cursor\u002F`, AGENTS.md, `.kiro`, `.claude`, and other tooling files that bloat build context:\n\n```dockerignore\n# Dependencies\nnode_modules\u002F\n.pnpm-store\u002F\nnpm-debug.log*\n\n# Build outputs\n.next\u002F\nout\u002F\ndist\u002F\nbuild\u002F\n.vercel\u002F\n\n# AI\u002FML tool metadata and configs\n.cursor\u002F\n.cursorrules\n.copilot\u002F\n.gemini\u002F\n.anthropic\u002F\n.kiro\n.claude\nAGENTS.md\n.agents\u002F\n\n# Tests\ncoverage\u002F\n__tests__\u002F\n*.test.*\n*.spec.*\n\n# Dev\n.git\u002F\n.vscode\u002F\n.env*\nDockerfile*\n.dockerignore\ncompose.yml\n\n# Docs\n*.md\ndocs\u002F\n\n# CI\n.github\u002F\n.gitlab-ci.yml\n\n# OS junk\n.DS_Store\nThumbs.db\n```\n\nThe full example: https:\u002F\u002Fgithub.com\u002Fvercel\u002Fnext.js\u002Fblob\u002Fcanary\u002Fexamples\u002Fwith-docker\u002F.dockerignore\n\n## Related Skills\n\n- `pnpm-monorepo-docker` — for pnpm **workspace monorepo** Docker builds. The standalone output path differs (nested under `apps\u002Fweb\u002F`). Load when building a monorepo package, not a standalone app.\n- `react-best-practices` — 70+ React\u002FNext.js performance optimization rules from Vercel Engineering\n\n## Verification\n\nAfter building, verify the runtime image:\n\n```bash\n# Check image size\ndocker images myapp-web\n\n# Verify no node_modules\ndocker run --rm myapp-web ls \u002Fapp\u002Fnode_modules 2>&1 || echo \"No node_modules — correct\"\n\n# Health check\ndocker run -d -p 3000:3000 myapp-web\ncurl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\n\n# Check process\ndocker exec \u003Ccontainer> ps aux | grep node\n```\n","# Next.js Docker Multi-Stage Build (Standalone Output)\n\n## When to Use\n\n- Creating or updating a Dockerfile for a standalone Next.js app (not a monorepo package)\n- Reviewing a Dockerfile that copies `node_modules` into the runtime image\n- Debugging large image sizes (>500MB) for a Next.js production container\n- **For pnpm workspace monorepo builds**, use `pnpm-monorepo-docker` instead (standalone output path differs)\n\n## The Problem\n\nNaive Dockerfiles copy `node_modules` directly into the final image:\n\n```dockerfile\nFROM node:22-alpine AS build\nWORKDIR \u002Fapp\nCOPY . .\nRUN npm install && npm run build\n\nFROM node:22-alpine\nWORKDIR \u002Fapp\nCOPY --from=build \u002Fapp\u002Fnode_modules .\u002Fnode_modules   # ← bloated, fragile\nCOPY --from=build \u002Fapp\u002F.next .\u002F.next\nCMD [\"npm\", \"start\"]\n```\n\nIssues:\n- **Image bloat** — `node_modules` includes dev deps (TypeScript, ESLint, vitest, etc.)\n- **OS-native binaries** — `sharp`, `@swc\u002Fcore` are built for the host arch, not the container's target arch\n- **Security surface** — every transitive dep is an extra CVE vector\n- **Startup overhead** — Node.js has to resolve modules from thousands of files\n\n## The Fix: Standalone Output\n\nNext.js `output: 'standalone'` traces all runtime dependencies into `.next\u002Fstandalone\u002F` — producing a self-contained bundle with only the code actually needed at runtime.\n\n**Two approaches for the Dockerfile build stage:**\n\n- **Multi-stage `deps` + `build` + `runtime`** (below) — uses `pnpm fetch` to populate the pnpm store in a deps layer, then `pnpm install --offline` to rebuild symlinks in build. Good for large monorepos where lockfile rarely changes. See `pnpm-monorepo-docker` §8 for symlink caveats.\n- **Single-stage `build` + `runtime`** — simpler, runs `pnpm install --frozen-lockfile --prod` directly. Layer caching still works because `package.json` and `pnpm-lock.yaml` change less often than source. Preferred for standalone apps where the extra `deps` stage adds complexity. See the Alternative box at the end of Step 2.\n\n**`--prod` vs `--no-dev`:** `--no-dev` is NOT a valid pnpm flag. It is silently ignored, causing ALL devDependencies to be installed. But `--prod` strips devDeps, which may be needed for the build (tailwindcss, postcss, typescript). **Strategy:**\n- **Multi-stage builds** (with a `deps` stage): Omit `--prod` in the build stage. Use `pnpm install --offline --frozen-lockfile` so devDeps are available for `next build`. The standalone runtime excludes them.\n- **Single-stage builds**: Use `pnpm install --frozen-lockfile --prod` but move build tools (tailwindcss, postcss, typescript) from devDependencies to dependencies in package.json.\n\n### Step 1: Enable standalone in next.config\n\n```ts\n\u002F\u002F next.config.ts\nconst nextConfig: NextConfig = {\n  output: 'standalone',\n  \u002F\u002F ... other config\n};\n```\n\n### Step 2: Multi-stage Dockerfile\n\n```dockerfile\n# ── Deps: install all dependencies ──\nFROM node:22-alpine AS deps\nRUN corepack enable && corepack prepare pnpm@10 --activate\nWORKDIR \u002Fapp\nCOPY pnpm-lock.yaml package.json .\u002F\nRUN pnpm fetch --frozen-lockfile\n\n# ── Build: compile the app ──\nFROM node:22-alpine AS build\nRUN corepack enable && corepack prepare pnpm@10 --activate\nWORKDIR \u002Fapp\nCOPY --from=deps \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY pnpm-lock.yaml package.json .\u002F\n# NOTE: No --prod flag — devDeps (tailwindcss, postcss, typescript) are\n# needed for next build. Standalone output traces only runtime deps,\n# so devDeps do not leak into the runtime image.\nRUN pnpm install --offline --frozen-lockfile\nCOPY . .\nRUN pnpm build\n\n# ── Runtime: standalone only ──\nFROM node:22-alpine AS runtime\nRUN addgroup --system --gid 1001 nodejs \\\n    && adduser --system --uid 1001 nextjs\nWORKDIR \u002Fapp\n\n# Copy standalone bundle (self-contained, no node_modules needed)\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstandalone .\u002F\n# Copy static assets (served by Next.js directly)\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\n# Copy public assets\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002Fpublic .\u002Fpublic\n\nUSER nextjs\nEXPOSE 3000\nENV PORT=3000\nCMD [\"node\", \"server.js\"]\n```\n\n**No ARG NEXT_PUBLIC_API_URL needed** when using Next.js rewrites. See \"Rewrites Alternative\" below.\n\nThe runtime image contains ONLY:\n- `server.js` + traced runtime code (~5-20MB)\n- `.next\u002Fstatic\u002F` (compiled chunks, ~200KB-2MB)\n- `public\u002F` (static assets)\n- No `node_modules\u002F`, no dev tools, no source files\n\n**Alternative — single-stage build (simpler, no `deps` stage):**\n\n```dockerfile\nFROM node:22-alpine AS build\nRUN corepack enable && corepack prepare pnpm@10 --activate\nWORKDIR \u002Fapp\n\n# Layer 1: deps (cached until package.json or lockfile changes)\nCOPY package.json pnpm-lock.yaml .npmrc .\u002F\nRUN pnpm install --frozen-lockfile --prod\n\n# Layer 2: source (invalidates on any file change)\nCOPY . .\nRUN pnpm build\n\nFROM node:22-alpine AS runtime\nRUN addgroup --system --gid 1001 nodejs \\\n    && adduser --system --uid 1001 nextjs\nWORKDIR \u002Fapp\n\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstandalone .\u002F\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\nCOPY --from=build --chown=nextjs:nodejs \u002Fapp\u002Fpublic .\u002Fpublic\n\nUSER nextjs\nEXPOSE 3000\nENV PORT=3000\nCMD [\"node\", \"server.js\"]\n```\n\nDocker layer caching still separates deps from source: Layer 1 caches on `package.json`\u002F`lockfile` content; Layer 2 on remaining source. This is simpler than the `deps` + `build` two-stage approach and avoids `pnpm fetch` symlink issues entirely.\n\n### Step 3: Build the image\n\n```bash\ndocker build --build-arg NEXT_PUBLIC_API_URL=http:\u002F\u002Fapi:8000 -t myapp-web .\n```\n\n## Alternative: Eliminate ARG with Next.js Rewrites\n\nInstead of baking `NEXT_PUBLIC_API_URL` into the client bundle at build time (which requires a build arg and causes cross-origin API calls), use Next.js rewrites to proxy API requests through the same origin:\n\n### Step A: API_BASE uses relative path\n\n```ts\n\u002F\u002F lib\u002Fapi\u002Findex.ts\nexport const API_BASE = process.env.NEXT_PUBLIC_API_URL || \"\u002Fapi\";\n```\n\nWhen `NEXT_PUBLIC_API_URL` is unset (no build arg), the client calls `\u002Fapi\u002Fauth\u002Flogin` (same-origin). When set (legacy config), it still works.\n\n### Step B: Add rewrites in next.config.ts\n\n```ts\n\u002F\u002F next.config.ts\nasync rewrites() {\n  return [\n    {\n      source: \"\u002Fapi\u002F:path*\",\n      destination: `${process.env.API_INTERNAL_URL || \"http:\u002F\u002Flocalhost:13202\"}\u002Fapi\u002F:path*`,\n    },\n  ];\n}\n```\n\nAt runtime, `API_INTERNAL_URL` tells the Next.js server where to forward API requests. In Docker Compose, set it to the internal service hostname.\n\n### Step C: Docker Compose sets API_INTERNAL_URL (not NEXT_PUBLIC_API_URL)\n\n```yaml\n# docker-compose.yml\nweb:\n  environment:\n    API_INTERNAL_URL: http:\u002F\u002Fapi:8000   # Docker internal DNS\n```\n\n### Step D: Add API_INTERNAL_URL as a Dockerfile build arg\n\n**CRITICAL: `next.config.ts` `async rewrites()` is evaluated at BUILD time, not runtime.** The rewrite destination is baked into the `required-server-files.json` during `next build`.\n\nThis means `process.env.API_INTERNAL_URL` in `next.config.ts` reads the build-time value, not the runtime container environment. You MUST pass it as a Dockerfile `ARG`:\n\n```dockerfile\nFROM node:22-alpine AS build\nARG API_INTERNAL_URL=http:\u002F\u002Fapi:8000\nENV API_INTERNAL_URL=$API_INTERNAL_URL\n```\n\nFor docker-compose, add it to the web service's `environment:` — it passes through to the build context:\n\n```yaml\nweb:\n  environment:\n    API_INTERNAL_URL: ${API_INTERNAL_URL:-http:\u002F\u002Fapi:8000}\n```\n\nIf the ARG is missing, the rewrite destination falls back to `\"http:\u002F\u002Flocalhost:13202\"` — which only works when the web server is on the host network, NOT inside Docker's internal network.\n\n### Combined example (Dockerfile + next.config + compose):\n\n**`next.config.ts`**:\n```ts\nasync rewrites() {\n  return [\n    {\n      source: \"\u002Fapi\u002F:path*\",\n      destination: `${process.env.API_INTERNAL_URL || \"http:\u002F\u002Flocalhost:13202\"}\u002Fapi\u002F:path*`,\n    },\n  ];\n}\n```\n\n**`Dockerfile`**:\n```dockerfile\nARG API_INTERNAL_URL=http:\u002F\u002Fapi:8000\nENV API_INTERNAL_URL=$API_INTERNAL_URL\n```\n\n**`docker-compose.yml`**:\n```yaml\nweb:\n  environment:\n    API_INTERNAL_URL: ${API_INTERNAL_URL:-http:\u002F\u002Fapi:8000}\n```\n\n### Benefits\n\n- **No CORS** — all requests are same-origin through the web server\n- **No build-time coupling** — the Docker image is independent of the API URL\n- **nginx compatibility** — if nginx is in front, it catches `\u002Fapi\u002F` before Next.js rewrites fire (no double-proxying)\n- **Cleaner separation** — build config (what the image needs at build) vs runtime config (where the backend lives)\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `Cannot find module 'next'` at runtime | Standalone not enabled, or COPY path wrong | Verify `output: 'standalone'` in next.config; check COPY destination |\n| `Error: ENOENT: no such file or directory` | Monorepo: standalone output is nested | Copy from `.next\u002Fstandalone\u002Fapps\u002Fweb\u002F` not `.next\u002Fstandalone\u002F` |\n| Image still >300MB | Static assets or public\u002F are too large | Audit `public\u002F` for binary files; use CDN for large assets |\n| New page routes return 404 in Docker, but host `next build` lists them | Standalone tracer's `.next\u002Fserver\u002F` directory (contains new route trees) is NOT copied into the runtime image | The multi-stage Dockerfile's `COPY --from=build \u002Fapp\u002F.next\u002Fstandalone .\u002F.next` copies the standalone bundle, and `COPY --from=build \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic` copies static chunks. But the tracer's **`.next\u002Fserver\u002F`** directory — which contains the server chunks for newly added route directories (admin\u002F, shares\u002F, publisher\u002Fsubmit\u002F, etc.) — is not copied unless explicitly added. **Fix:** Add `COPY --from=build \u002Fapp\u002F.next\u002Fserver .\u002F.next\u002Fserver` after the standalone and static copies in the runtime stage. This is deterministic — `--no-cache` rebuild alone does NOT fix it because the tracer output is correct in the build stage; the missing step is the COPY directive. |\n| `pnpm build` fails with `No projects matched` | Wrong filter name in monorepo | Check exact package name from package.json |\n| `sharp` fails to load | Native binary mismatch | Ensure native deps are built in the same arch as runtime (Alpine uses musl) |\n| `node: not found` | Alpine image mismatch | Use `node:22-alpine` consistently across all stages |\n| `COPY public .\u002Fpublic fails` | No `public\u002F` directory exists | Remove the COPY line or create the directory. Many Next.js apps have no static public assets. |\n| `pnpm approve-builds` hangs at build time | `approve-builds` is interactive (requires TTY); Docker build has no TTY | Never call `pnpm approve-builds` in a Dockerfile. Instead, configure `only-built-dependencies[]` in `.npmrc` at the project root. |\n| `Node.js 18+ module not found` at runtime with standalone output | Standalone tracing via `@vercel\u002Fnft` incorrectly marks modules as not used | Set `experimental.outputFileTracingIncludes` in `next.config.ts` to force-include missing modules |\n| **`.dockerignore` excludes root `node_modules\u002F` but NOT nested ones — 489MB build context** | `.dockerignore` pattern `node_modules\u002F` only matches root-level. Nested dirs like `web\u002Fnode_modules\u002F` (352MB) are still sent to the Docker daemon. Context transfer stalls at 30+ seconds; build may time out. | Use `**\u002Fnode_modules\u002F` to exclude ALL nested `node_modules` dirs. Verify with `docker buildx build --progress=plain` — context transfer should be \u003C5MB for a Next.js project. |\n| **Docker build hangs after `docker system prune` (cold cache)** | `pnpm install` re-downloads 46+ packages, then `next build` compiles from scratch. | **Fallback:** Build standalone locally, then create a minimal Docker image. |\n| **Tailwind CSS not applied** | `postcss.config.ts` is silently ignored by Next.js 15. Must be `.mjs` or `.js`. CSS contains raw @tailwind directives, no utility classes. | Rename to `postcss.config.mjs`, delete old `.ts`. |\n| **pnpm install --prod strips tailwindcss** | If tailwindcss, postcss, autoprefixer are in devDependencies, --prod skips them. | Move to dependencies in package.json, update lockfile. |\n\n### Next.js 16 TypeScript Strictness — Build-Only Failures\n\n> **Build caching reference:** See `references\u002Fdocker-build-caching.md` for cache mount patterns (`.next\u002Fcache`, pnpm store), the `--no-dev` → `--prod` fix, and the pre-test rebuild ritual.\n\nNext.js 16's Turbopack compiler is stricter about JSX types than v15. These errors may not appear in `tsc` or local dev but will fail `next build` (and therefore Docker builds):\n\n| Error | Pattern | Fix |\n|-------|---------|-----|\n| `Type 'unknown' is not assignable to type 'ReactNode'` | `{state.data && \u003CComponent \u002F>}` where `data: unknown \\| null` | Use `{!!state.data && \u003CComponent \u002F>}` — the `!!` coerces `unknown` to `boolean` which is valid JSX |\n| `Property 'defaultOpen' does not exist on type '...HTMLDetailsElement...'` | `\u003Cdetails defaultOpen={bool}>` — React 19 added `defaultOpen` but TS types may not include it yet | Use `open={bool}` instead (controlled), or add `@ts-expect-error` |\n| `Inferred workspace root may not be correct` | pnpm monorepo + Turbopack can't auto-detect workspace root in Docker | Set `outputFileTracingRoot: path.resolve(__dirname, \"..\u002F..\u002F\")` at the **top level** of `next.config.ts` (NOT under `experimental`). Also add `transpilePackages: [\"\u003Cpackage-name>\"]` |\n| `Object literal may only specify known properties, but 'outputFileTracingRoot' does not exist in type 'NextConfig'` | LSP thinks it belongs under `experimental` — but the Zod schema validates it at top level | Ignore the LSP diagnostic; the compiler accepts it. If it doesn't, wrap in `experimental: { outputFileTracingRoot: ... }` |\n\n**Verification after build fix:**\n```bash\n# Run build locally first (fast iteration)\ncd apps\u002Fweb && pnpm build 2>&1 | tail -5\n\n# Then rebuild Docker\ndocker compose build --no-cache web\n\n# Verify routes in container\ndocker compose exec web find \u002Fapp\u002Fapps\u002Fweb\u002F.next\u002Fserver\u002Fapp -name \"page.js\" 2>\u002Fdev\u002Fnull | sort | head -30\n```\n\n## Official Vercel Patterns\n\nThe [official Next.js Docker example](https:\u002F\u002Fgithub.com\u002Fvercel\u002Fnext.js\u002Ftree\u002Fcanary\u002Fexamples\u002Fwith-docker) provides additional production patterns.\n\n### ARG NODE_VERSION for Easier Maintenance\n\nParameterize the Node.js version so it can be updated in one place:\n\n```dockerfile\nARG NODE_VERSION=24.13.0-slim\n\nFROM node:${NODE_VERSION} AS dependencies\nWORKDIR \u002Fapp\nCOPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* .\u002F\nRUN --mount=type=cache,target=\u002Froot\u002F.npm \\\n    --mount=type=cache,target=\u002Fusr\u002Flocal\u002Fshare\u002F.cache\u002Fyarn \\\n    --mount=type=cache,target=\u002Froot\u002F.local\u002Fshare\u002Fpnpm\u002Fstore \\\n    if [ -f package-lock.json ]; then \\\n      npm ci --no-audit --no-fund; \\\n    elif [ -f yarn.lock ]; then \\\n      corepack enable yarn && yarn install --frozen-lockfile --production=false; \\\n    elif [ -f pnpm-lock.yaml ]; then \\\n      corepack enable pnpm && pnpm install --frozen-lockfile; \\\n    fi\n\nFROM node:${NODE_VERSION} AS builder\nWORKDIR \u002Fapp\nCOPY --from=dependencies \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nRUN if [ -f package-lock.json ]; then \\\n      npm run build; \\\n    elif [ -f yarn.lock ]; then \\\n      corepack enable yarn && yarn build; \\\n    elif [ -f pnpm-lock.yaml ]; then \\\n      corepack enable pnpm && pnpm build; \\\n    fi\n\nFROM node:${NODE_VERSION} AS runner\nWORKDIR \u002Fapp\nENV NODE_ENV=production\nENV PORT=3000\nENV HOSTNAME=\"0.0.0.0\"\nCOPY --from=builder --chown=node:node \u002Fapp\u002Fpublic .\u002Fpublic\nRUN mkdir .next && chown node:node .next\nCOPY --from=builder --chown=node:node \u002Fapp\u002F.next\u002Fstandalone .\u002F\nCOPY --from=builder --chown=node:node \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\nUSER node\nEXPOSE 3000\nCMD [\"node\", \"server.js\"]\n```\n\nThe `ARG` pattern supports npm, yarn, AND pnpm in a single Dockerfile — useful when the project's package manager could vary.\n\n### slim vs alpine\n\n| Base | Size | Libc | Compatibility |\n|------|------|------|---------------|\n| `slim` (glibc) | ~226MB | glibc | Best npm package compatibility |\n| `alpine` (musl) | ~126MB | musl | May break native deps (sharp, @swc\u002Fcore) |\n\n**Use slim when:** compatibility matters more than 100MB savings. Most production deployments should use slim.  \n**Use alpine when:** image size is critical AND you've verified all native dependencies work with musl.\n\n### Bun Runtime Alternative\n\nFor projects using Bun instead of Node.js:\n\n```dockerfile\nFROM oven\u002Fbun:1 AS dependencies\nWORKDIR \u002Fapp\nCOPY package.json bun.lock* .\u002F\nRUN --mount=type=cache,target=\u002Froot\u002F.bun\u002Finstall\u002Fcache \\\n    bun install --no-save --frozen-lockfile\n\nFROM oven\u002Fbun:1 AS builder\nWORKDIR \u002Fapp\nCOPY --from=dependencies \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nENV NODE_ENV=production\nRUN bun run build\n\nFROM oven\u002Fbun:1 AS runner\nWORKDIR \u002Fapp\nENV NODE_ENV=production PORT=3000 HOSTNAME=\"0.0.0.0\"\nCOPY --from=builder --chown=bun:bun \u002Fapp\u002Fpublic .\u002Fpublic\nRUN mkdir .next && chown bun:bun .next\nCOPY --from=builder --chown=bun:bun \u002Fapp\u002F.next\u002Fstandalone .\u002F\nCOPY --from=builder --chown=bun:bun \u002Fapp\u002F.next\u002Fstatic .\u002F.next\u002Fstatic\nUSER bun\nEXPOSE 3000\nCMD [\"bun\", \"server.js\"]\n```\n\n### Production .dockerignore\n\nThe official example includes AI\u002FML metadata in `.dockerignore` — exclude `.cursor\u002F`, AGENTS.md, `.kiro`, `.claude`, and other tooling files that bloat build context:\n\n```dockerignore\n# Dependencies\nnode_modules\u002F\n.pnpm-store\u002F\nnpm-debug.log*\n\n# Build outputs\n.next\u002F\nout\u002F\ndist\u002F\nbuild\u002F\n.vercel\u002F\n\n# AI\u002FML tool metadata and configs\n.cursor\u002F\n.cursorrules\n.copilot\u002F\n.gemini\u002F\n.anthropic\u002F\n.kiro\n.claude\nAGENTS.md\n.agents\u002F\n\n# Tests\ncoverage\u002F\n__tests__\u002F\n*.test.*\n*.spec.*\n\n# Dev\n.git\u002F\n.vscode\u002F\n.env*\nDockerfile*\n.dockerignore\ncompose.yml\n\n# Docs\n*.md\ndocs\u002F\n\n# CI\n.github\u002F\n.gitlab-ci.yml\n\n# OS junk\n.DS_Store\nThumbs.db\n```\n\nThe full example: https:\u002F\u002Fgithub.com\u002Fvercel\u002Fnext.js\u002Fblob\u002Fcanary\u002Fexamples\u002Fwith-docker\u002F.dockerignore\n\n## Related Skills\n\n- `pnpm-monorepo-docker` — for pnpm **workspace monorepo** Docker builds. The standalone output path differs (nested under `apps\u002Fweb\u002F`). Load when building a monorepo package, not a standalone app.\n- `react-best-practices` — 70+ React\u002FNext.js performance optimization rules from Vercel Engineering\n\n## Verification\n\nAfter building, verify the runtime image:\n\n```bash\n# Check image size\ndocker images myapp-web\n\n# Verify no node_modules\ndocker run --rm myapp-web ls \u002Fapp\u002Fnode_modules 2>&1 || echo \"No node_modules — correct\"\n\n# Health check\ndocker run -d -p 3000:3000 myapp-web\ncurl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\n\n# Check process\ndocker exec \u003Ccontainer> ps aux | grep node\n```\n",{"name":5,"author":24,"version":25,"metadata":26,"description":7},"Steadfaste Fleet","1.0.0",{"tags":27},[28,29,30,31,32],"nextjs","docker","multi-stage","standalone","best-practices","main","2e6aa8d15ab0a366c90be54f61bf9c6e97015e83","skills\u002Fdevops\u002Fnextjs-docker-multistage",1,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet","steadfaste.com","https:\u002F\u002Fgithub.com\u002Flukemcqueen","AI Architect | Building Hermes Cortex: governed multi-agent AI for autonomous software engineering | Enterprise Tech Consultant","2026-11-14 22:33:34",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add lukemcqueen\u002Fsteadfaste-fleet --skill nextjs-docker-multistage",{"tool":48,"command":49},"bunx","bunx skills add lukemcqueen\u002Fsteadfaste-fleet --skill nextjs-docker-multistage",{"tool":51,"command":52},"pnpm","pnpm dlx skills add lukemcqueen\u002Fsteadfaste-fleet --skill nextjs-docker-multistage","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fnextjs-docker-multistage\u002FSKILL.md",true,[56],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fdocker-build-caching.md","REFERENCE","参考文档",1911,"https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fnextjs-docker-multistage\u002Freferences\u002Fdocker-build-caching.md",[63,71,78,85,92,99],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":70},"01M7DXY4G8NSVB59K8B6S2AQNP","macbook-linux-maintenance","Legacy MacBook Linux fixes: GPU wedge, reboot hang, thermal.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fmacbook-linux-maintenance\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":70},"01M7DXXYJCXFJ3TGB84ZQ8KFE6","governance-regression-triage","Triage a host's governance issues: what changed.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fgovernance-regression-triage\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":70},"01M7DXXSAP1G8FDRJAMXQGBBMK","enforcement-immutability","Use when enforcement files lose their immutable flag.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fenforcement-immutability\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":70},"01M78SSDQVRYX64Y16X32TC0NS","steadfaste-fleet-repo-deploy","Use when committing to the steadfaste-fleet repo.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-repo-deploy\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":70},"01M78SS928F3R2RJAYVW4E30CE","steadfaste-fleet-maintenance","Maintain an installed Steadfaste Fleet instance — update both the upstream Hermes Agent and the fleet repo layer, merge diverged histories, sync skills safely, and troubleshoot common issues. Covers the dual-update workflow (hermes update + fleet-update.sh), encrypted brain data backup, mycortex import, and recovery techniques.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Fsteadfaste-fleet-maintenance\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":70},"01M78SP1CHW0T0BWE5ZT6JBPX8","fleet-preflight","DEPRECATED alias — merged into survey-before-action (2026-08-20). Load survey-before-action instead; its \"Repo-Specific Pre-Flight\" section covers git search, Hermes boundary, and deployment verification.","https:\u002F\u002Fgithub.com\u002Flukemcqueen\u002Fsteadfaste-fleet\u002Fblob\u002Fmain\u002Fskills\u002Fdevops\u002Ffleet-preflight\u002FSKILL.md",[],[]]