Next.js 应用如何部署?Vercel 之外怎么自建?
Vercel(官方):git push 即部署,自动识别 Next、配置 Serverless Function 与边缘缓存,最省心。
自建 / 容器:
next build产出.next/next start启动 Node 服务(需 Node 运行时,支持 SSR/ISR)- 配置
output: 'standalone'可产出精简自包含服务(含运行时依赖),极适合 Docker
FROM node:18-alpine
COPY .next/standalone ./
COPY .next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]纯静态导出用
output: 'export'(但会失去 SSR/ISR/Server Actions,只剩 SSG)。