v0.7.4 Star
Guides

Next.js apps

Railpack detects Next.js automatically. A few settings make builds faster and images smaller.

Use standalone output

Set output: 'standalone' so the image only contains what the server needs. Dockyrd shows a hint on the app page when it is missing, but it is never required.

import type { NextConfig } from 'next'

const config: NextConfig = {
  output: 'standalone',
}

export default config

Public variables need a rebuild

Variables starting with NEXT_PUBLIC_ are inlined into the client bundle at build time. Dockyrd marks them as build-time automatically and shows that changing one triggers a rebuild, not just a restart.

Add a health check

By default Dockyrd waits until the port accepts connections. For a stricter check, set Health path to a route that returns 200 once the app can serve traffic:

export function GET() {
  return Response.json({ ok: true })
}

Builds on small servers

Next.js builds are memory hungry. On a 1 GB server the installer adds swap so builds finish, but they are slow. Use 2 vCPU and 4 GB if you build often, or build in CI and deploy the resulting image.

Edit this page on GitHubApache-2.0 licensed
Esc