Next.js Discord

Discord Forum

HELP PLEASE - Next.js Docker container size increases rapidly

Unanswered
Waqas posted this in #help-forum
Open in Discord
I have a live project called Caterbee. I'm facing an issue where the Docker container size increases rapidly after deployment, especially when users use the site. The site uses many images, and I discovered that the cache directory is causing this rapid increase. Can anyone help me resolve this problem? As the container size multiplies, it fills up the server space and causes a 502 gateway error for users.

2 Replies

Sun bear
are you storing images in the "/public" directory?
No, the images are being served from the CDN, and by default, Next.js stores them in .next/cache/images/* as the images are loaded.

At the time of deployment, the build size is fine, but when users start visiting the pages, the container size starts growing in GBs in a few hours.