Deploy with Docker

For self-hosted deployments, NextGenKit can be containerized.

Dockerfile

Create a Dockerfile in the project root:

FROM node:20-alpine AS base
RUN corepack enable && corepack prepare pnpm@latest --activate

FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile

FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm build

FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public

EXPOSE 3000
CMD ["node", "server.js"]

Build and Run

docker build -t nextgenkit .
docker run -p 3000:3000 --env-file .env.local nextgenkit

Next.js Standalone Output

Add to next.config.mjs:

const nextConfig = {
  output: "standalone",
}

This produces a minimal server.js that can run without node_modules.