DEV Community

Discussion on: A gotcha with Next.js production builds in Docker Compose

Collapse
 
tbroyer profile image
Thomas Broyer

One small nit: always use exec for the last command in your entrypoint script (exec npm run build) such that the npm process will receive signals (such as SIGTERM to stop the container) rather than the script. Without it, the shell will receive the signals and ignore them (that's how it works when it's PID 1), do after a timeout the Docker daemon will force-kill (SIGKILL) it.

Now if you fetch data from an external data source, how about using incremental static generation? That way, IIUC, you could build the site upfront without the need for that data (but then pay the cost of generation on first access to a page 🤷‍♂️)