High CPU Usage in Docker when running Nuxt in dev
When I run nuxt with
yarn run dev
in my docker container, the CPU usage of the container is high. Also, every few seconds, the logs output this:
I don't know if that is expected behavior, but when I run yarn run dev
outside of the container, the CPU usage is a lot lower and the nitro-runtime logs don't occur.
Here's my Dockerfile:
and my compose file for the frontend container:
5 Replies
and my nuxt.config.ts:
Here's a minimal app with docker that reproduces the issue:
https://github.com/tmorgan497/minimal-nuxt-docker
GitHub
GitHub - tmorgan497/minimal-nuxt-docker: A minimal Nuxt App with Do...
A minimal Nuxt App with Docker. Contribute to tmorgan497/minimal-nuxt-docker development by creating an account on GitHub.
I may have narrowed it down to chokidar. When i comment out the environment variable
CHOKIDAR_USEPOLLING=true
, the CPU usage goes down to a normal level (under 1%). IIRC, chokidar is used for HMR, so I usually leave it active during development so I don't have to restart the container everytime I make a change. Any thoughts on how to reduce its CPU usage? I added a watcher ignore param to my nuxt.config.ts, but it doesn't seem to do anything to help reduce the CPU usage.
I created a new issue on the nuxt github. https://github.com/nuxt/nuxt/issues/27617
GitHub
High CPU Usage with Nuxt Dev Server in Docker · Issue #27617 · nuxt...
Environment - Operating System: Windows_NT - Node Version: v20.10.0 - Nuxt Version: - - CLI Version: 3.12.0 - Nitro Version: - - Package Manager: unknown - Builder: - - User Config: - - Runtime Mod...
Tested on NixOS. I don't get the same issue with high CPU usage. Maybe it's a Windows issue only. I'll try to rule out an issue with my own machine by running it on another Windows machine when I get a chance.
https://github.com/nuxt/nuxt/issues/27617#issuecomment-2173371370
GitHub
High CPU Usage with Nuxt Dev Server in Docker · Issue #27617 · nuxt...
Environment - Operating System: Windows_NT - Node Version: v20.10.0 - Nuxt Version: - - CLI Version: 3.12.0 - Nitro Version: - - Package Manager: unknown - Builder: - - User Config: - - Runtime Mod...