tmorgan497
tmorgan497
NNuxt
Created by tmorgan497 on 6/13/2024 in #❓・help
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:
frontend-container | [nitro-runtime] request: 0.04ms
frontend-container | [nitro-runtime] render:html: 0.058ms
frontend-container | [nitro-runtime] render:response: 0.009ms
frontend-container | [nitro-runtime] beforeResponse: 0.006ms
frontend-container | [nitro-runtime] dev:ssr-logs: 0.007ms
frontend-container | [nitro-runtime] afterResponse: 0.306ms
frontend-container | [nitro-runtime] request: 0.039ms
frontend-container | [nitro-runtime] request: 0.04ms
frontend-container | [nitro-runtime] render:html: 0.058ms
frontend-container | [nitro-runtime] render:response: 0.009ms
frontend-container | [nitro-runtime] beforeResponse: 0.006ms
frontend-container | [nitro-runtime] dev:ssr-logs: 0.007ms
frontend-container | [nitro-runtime] afterResponse: 0.306ms
frontend-container | [nitro-runtime] request: 0.039ms
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:
# frontend/frontend.Dockerfile
FROM node:20.10.0-alpine AS dev
ENV HOST 0.0.0.0
WORKDIR /code/frontend
RUN apk --no-cache add curl
COPY package.json ./
RUN yarn cache clean && yarn install
COPY . .
# frontend/frontend.Dockerfile
FROM node:20.10.0-alpine AS dev
ENV HOST 0.0.0.0
WORKDIR /code/frontend
RUN apk --no-cache add curl
COPY package.json ./
RUN yarn cache clean && yarn install
COPY . .
and my compose file for the frontend container:
frontend:
env_file:
- ./.env
environment:
- BASE_URL=${BASE_URL}
working_dir: /code/frontend
container_name: ${FRONTEND_CONTAINER_NAME:-frontend}
build:
context: ./frontend
dockerfile: ./frontend.Dockerfile
target: ${STAGE:-dev}
ports:
- ${FRONTEND_9000_PORT:-9000}:9000
- ${FRONTEND_8080_PORT:-8080}:8080
- 3000:3000
volumes:
- ./frontend:/code/frontend:rw
- frontend_node_modules:/code/frontend/node_modules
tmpfs: /tmp
command: /bin/sh -c "cd /code/frontend && yarn run dev --host"
frontend:
env_file:
- ./.env
environment:
- BASE_URL=${BASE_URL}
working_dir: /code/frontend
container_name: ${FRONTEND_CONTAINER_NAME:-frontend}
build:
context: ./frontend
dockerfile: ./frontend.Dockerfile
target: ${STAGE:-dev}
ports:
- ${FRONTEND_9000_PORT:-9000}:9000
- ${FRONTEND_8080_PORT:-8080}:8080
- 3000:3000
volumes:
- ./frontend:/code/frontend:rw
- frontend_node_modules:/code/frontend/node_modules
tmpfs: /tmp
command: /bin/sh -c "cd /code/frontend && yarn run dev --host"
6 replies