nextjs-coolify-image
Package a Next.js app as a runtime-only container image with a health probe and a fast shutdown.
Skill by KhaledSaeed18
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/khaledsaeed18-nextjs-coolify-image
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend, devops
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Node.js package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/nextjs-coolify-image
What's inside
- Skill name
nextjs-coolify-image- Description
- Package a Next.js app as a runtime-only container image with a health probe and a fast shutdown. Use when containerising a Next.js app, when its image is large or slow, or when a rolling update drops requests.
- License
- MIT
- Instructions
- 53 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
- Instructions call the network
Files (6)
- SKILL.md
- Dockerfile · templates/
- dockerignore · templates/
- healthcheck.js · templates/
- healthz-route.ts · templates/
- shutdown.cjs · templates/
SKILL.md (first lines)
The image contains the standalone server and nothing else: the build runs natively in CI, the Dockerfile only copies output, and the container proves its own readiness and leaves within a second when asked. Those three properties make rolling updates safe and images small; everything below enforces them.
## Hard rules: never break these
- **Build on the runner, never in Docker and never on the server.** Registry installs inside container builds hang; the server has no spare CPU. The Dockerfile copies `.next/standalone`, `.next/static` and `public` only.
- **`output: "standalone"` with no `NEXT_DIST_DIR` override at build time**, so the output lands in `.next`.
- **Public env is baked at build time.** Every `NEXT_PUBLIC_*` value and the `/api` rewrite destination are inlined; set them in the workflow before `next build` and verify them in `.next/routes-manifest.json`. Only server-only runtime secrets go to Coolify.
- **The health route lives outside anything proxied or localised.** `/healthz` sits beside `app/api`, not under it, and the proxy matcher excludes it.
- **Exit within a second on SIGTERM.** Next waits for in-flight requests; a long-lived stream (SSE, a WebSocket) keeps the old container alive for the whole grace period while the proxy still routes to it.
- **No `latest` tags, no root user, no host ports.**
## Step 1: Audit the app
```bash
grep -n "output\|distDir\|rewrites\|headers" next.config.*
grep -rn "process.env" app components lib proxy.ts middleware.ts 2>/dev/null | grep -v NEXT_PUBLIC_ | grep -v node_modules
grep -rln "next/image" app components | head
```
Classify every env read as build-time (`NEXT_PUBLIC_*`, anything in `next.config`) or runtime (read on the server at request time). Note whether `next/image` optimises local images: sharp is traced into the standalone output automatically when installed, so the runtime image needs no extra packages, but the smoke test must prove it.
## Step 2: Add the runtime files
Copy and adapt, from `templates/`:
| File | Purpose |
| --- | --- |
| [Dockerfile](./templates/Dockerfile) | `node:<major>-slim`, copies the three output folders plus the two scripts, `USER node`, `HEALTHCHECK` on the probe, exit deadline preloaded |
| [.dockerignore](./templates/dockerignore) | an allowlist: everything out except the build output |
| [healthcheck.js](./templates/healthcheck.js) | fetches `/healthz` on `127.0.0.1` with a 4 s timeout, exit 0 or 1 |
| [shutdown.cjs](./templates/shutdown.cjs) | exits half a second after SIGTERM or SIGINT; `NEXT_MANUAL_SIG_HANDLE=true` in the Dockerfile disables Next's own wait |
| [healthz route](./templates/healthz-route.ts) | `app/healthz/route.ts`, static, `Cache-Control: no-store` |
In `next.config.*`: `output: "standalone"`, `poweredByHeader: false`, and send `Strict-Transport-Security` yourself (a platform edge used to add it; a self-hosted proxy does not). In the proxy or middleware matcher add `healthz` to the exclusions: `"/((?!api|healthz|_next|.*\\..*).*)"`. Add the new files to knip or lint ignores if the repo gates unused files.
## Step 3: Build and verify the baked values locally
```bash
NEXT_PUBLIC_API_BASE_URL=https://api.example.com pnpm build
jq -r '.rewrites.afterFiles[]?, .rewrites.beforeFiles[]?, .rewrites.fallback[]? | select(.source == "/api/:path*") | .destination' .next/routes-manifest.json
ls .next/standalone/node_modules/.pnpm | grep -c sharp # non-zero when next/image is used
docker build -t app:local . && docker image inspect app:local --format '{{.Size}}'
```
## Step 4: Smoke-test the image the way CI will
Run the container with the memory limit and check, in order: Docker reports `healthy` within 30 s; `id -u` is not 0; `/healthz` 200; a page per locale (`dir="rtl"` present where expected); an unauthenticated protected route redirects to login; security headers present and `x-powered-by` absent; `/_next/image?url=...` returns `image/*` when the app optimises images; `docker stop -t 10` returns in about a second. Write curl output to files before grepping: `grep -q` closes the pipe early and fails curl under `pipefail`. The exact script is the image job in the `ghcr-coolify-pipeline` skill.
## Step 5: Hand over
Report the image size, the verified rewrite destination, the smoke results, which env values are baked and which are runtime, and anything the app does that the probe does not cover (background jobs, streams). The Coolify side is the `coolify-image-app` skill; the general container rules the `dockerfile-best-practices` skill.From KhaledSaeed18/dotclaude, MIT.
More from KhaledSaeed18/dotclaude
- 0.619score
ghcr-coolify-pipeline
KhaledSaeed18
Write the single GitHub Actions workflow that takes a repository from pull request to production through GHCR and Coolify.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
coolify-image-app
KhaledSaeed18
Create and configure a Coolify application that runs a prebuilt image from a registry.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
coolify-vps-baseline
KhaledSaeed18
Prepare a Linux VPS to run production containers under Coolify.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
deploy-verification
KhaledSaeed18
Prove a deployment from the server side.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
express-prisma-coolify-image
KhaledSaeed18
Package an Express and Prisma API as a runtime-only image that migrates its Postgres database at start.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
live-domain-cutover
KhaledSaeed18
Move a live domain from one host to another without downtime or lost sessions, with a rehearsal, a timed DNS switch, a soak and the old host removed.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
proxy-client-address
KhaledSaeed18
Forward the real client address from a server-side proxy to a backend without trusting forgeable headers.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
vps-ops-toolkit
KhaledSaeed18
Install host operations on a VPS, with a cron health check that alerts on change, restore-verified encrypted database backups, and an installer.
SkillAFreshness: A★ 5Claude Code +9 - 0.579score
dockerfile-best-practices
KhaledSaeed18
Write or review a Dockerfile and compose setup for a production service: multi-stage builds that ship only the runtime, pinned base images, layer order for…
SkillBFreshness: B★ 5Claude Code +9 - 0.579score
adr-writing
KhaledSaeed18
Write Architecture Decision Records that a future engineer can act on: a numbered, immutable record with the context that forced the decision, the options…
SkillBFreshness: B★ 5Claude Code +9 - 0.579score
openapi-spec
KhaledSaeed18
Write, generate, or review an OpenAPI 3.1 specification for an HTTP API so that it is accurate to the implementation, complete for consumers (schemas…
SkillBFreshness: B★ 5Claude Code +9 - 0.579score
api-design-review
KhaledSaeed18
Review an API contract (REST or GraphQL) before or while it is implemented, checking resource naming, HTTP semantics, status codes, error shape, pagination…
SkillBFreshness: B★ 5Claude Code +9
Signals
- Stars
- 5
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 5, 2026 (23 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/KhaledSaeed18/dotclaude
- Website
- dotclaude.khaledsaeed.tech/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from KhaledSaeed18
- 0.619score
ghcr-coolify-pipeline
KhaledSaeed18
Write the single GitHub Actions workflow that takes a repository from pull request to production through GHCR and Coolify.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
coolify-image-app
KhaledSaeed18
Create and configure a Coolify application that runs a prebuilt image from a registry.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
coolify-vps-baseline
KhaledSaeed18
Prepare a Linux VPS to run production containers under Coolify.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
deploy-verification
KhaledSaeed18
Prove a deployment from the server side.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
express-prisma-coolify-image
KhaledSaeed18
Package an Express and Prisma API as a runtime-only image that migrates its Postgres database at start.
SkillAFreshness: A★ 5Claude Code +9 - 0.619score
live-domain-cutover
KhaledSaeed18
Move a live domain from one host to another without downtime or lost sessions, with a rehearsal, a timed DNS switch, a soak and the old host removed.
SkillAFreshness: A★ 5Claude Code +9
Cite this page
nextjs-coolify-image skill. Agent Mart. https://agentmart.dev/skills/khaledsaeed18-nextjs-coolify-image (last updated 2026-10-24)