Skip to main content

Idle Resource Bloat - Build on Startup Loop Risk

This report documents a production hardening case where the site appeared "bloated" even without active user browsing.

Symptom

  • Perceived resource bloat while idle.
  • Historical behavior showed repeated Docusaurus build attempts after container restarts.
  • Previous incident logs confirmed build-loop patterns can consume CPU/IO even without normal user sessions.

Root Cause Pattern

The service was configured to run:

npm run start

And start in package.json is:

docusaurus build && docusaurus serve --host 0.0.0.0 --port 3000

Impact:

  1. Every container restart triggers a full production build.
  2. If content validation fails, container can enter restart/build loops.
  3. Even with low/no user traffic, rebuild cycles create CPU/IO "bloat" and noisy tunnel errors.

Fix Applied

Updated Compose command to serve existing build directly in production.

File changed:

  • /opt/docker-data/apps/docusaurus/docker-compose.yml

Change:

command: npm run prod

Where prod is:

docusaurus serve --host 0.0.0.0 --port 3000

Then container was recreated:

sudo docker compose up -d docusaurus

Validation

  • Runtime command confirmed:
    • npm run prod
  • Logs showed direct static serving (no rebuild step):
    • Serving "build" directory at: http://0.0.0.0:3000/
  • Resource usage stayed low at idle.
  • Public endpoint remained healthy behind Access (302 redirect), no 502.

Operational Guidance

  1. Build intentionally (npm run build) during deploy windows, not on every container start.
  2. Keep production command on serve only.
  3. Add pre-deploy validation to catch frontmatter/MDX errors before restart.
  4. If updating content frequently, use a deploy script that runs build first, then restarts container only on success.