In nextjs, how to keep files from previous build to prevent missing file error

Viewed 86

When a nextjs app is deployed in a docker container, a new build wipes out the files from the previous build. In this case, when a client request a file from the previous build (because they have not refreshed the page and are using the files from the previous build), they could potentially get a runtime error because the file does not exist in the new container. What is the recommended approach to solve this problem?

1 Answers

Use cleanDistDir: false in next.config.js to preserve previous build files. But you probably need to create your builds outside docker and pull / copy them into your docker container.

Related