generateBuildId
Next.js 在 next build
期间生成一个 ID,以识别正在提供的应用版本。应使用相同的构建并启动多个容器。
¥Next.js generates an ID during next build
to identify which version of your application is being served. The same build should be used and boot up multiple containers.
如果你要为环境的每个阶段进行重建,则需要生成一致的构建 ID 以在容器之间使用。在 next.config.js
中使用 generateBuildId
命令:
¥If you are rebuilding for each stage of your environment, you will need to generate a consistent build ID to use between containers. Use the generateBuildId
command in next.config.js
:
module.exports = {
generateBuildId: async () => {
// This could be anything, using the latest git hash
return process.env.GIT_HASH
},
}