Next.js + Docker
Multi-stage Dockerfile: nginx for static sites, a Node server for apps that need one. This page shows exactly what pickstack adds to a Next.js project for Docker: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.
$ npm create pickstack@latest my-app -- --framework next --modules docker --yesCustomize in the configurator
New files
node_modules dist build .output .nuxt .next .svelte-kit .astro .angular .git .env .env.* !.env.example *.log Dockerfile .dockerignore
# syntax=docker/dockerfile:1 FROM node:24-alpine AS build WORKDIR /app COPY package.json package-lock.json* ./ RUN npm install COPY . . RUN mkdir -p public RUN npm run build FROM node:24-alpine WORKDIR /app ENV NODE_ENV=production ENV PORT=3000 ENV HOSTNAME=0.0.0.0 COPY --from=build --chown=node:node /app/public ./public COPY --from=build --chown=node:node /app/.next/standalone ./ COPY --from=build --chown=node:node /app/.next/static ./.next/static USER node EXPOSE 3000 CMD ["node", "server.js"]
Changes to existing files
import type { NextConfig } from "next"; +const nextConfig: NextConfig = { output: "standalone" };−const nextConfig: NextConfig = {}; export default nextConfig;
Project files
.dockerignore.gitignoreDockerfileREADME.mdapp/about/page.tsxapp/globals.cssapp/layout.tsxapp/page.tsxcomponents/Counter.tsxnext.config.tspackage.jsontsconfig.json