pickstack

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 --yes
Customize in the configurator

New files

.dockerignore
node_modules
dist
build
.output
.nuxt
.next
.svelte-kit
.astro
.angular
.git
.env
.env.*
!.env.example
*.log
Dockerfile
.dockerignore
Dockerfile
# 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

next.config.ts (changed)
 import type { NextConfig } from "next";  +const nextConfig: NextConfig = { output: "standalone" };−const nextConfig: NextConfig = {};   export default nextConfig;  

Project files

Related templates