fix(docker): prevent static asset 404s by waiting for webpack dev server#38161
Open
fix(docker): prevent static asset 404s by waiting for webpack dev server#38161
Conversation
When running `docker compose up`, nginx would start immediately and begin proxying `/static` requests to port 9000 (webpack dev server) before the `superset-node` container had finished running `npm install` and starting the dev server. This resulted in 404 errors for all static assets. This fix adds: 1. A health check to `superset-node` that verifies the webpack dev server is responding on port 9000 2. A `depends_on` condition on `nginx` that waits for `superset-node` to be healthy before starting The health check: - Uses Node.js (already available in the container) to make HTTP requests - Has a 60-second start period to allow for `npm install` - Retries up to 30 times at 10-second intervals (5+ minutes total) - Prevents nginx from proxying to a non-existent server Fixes #30183 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
|
Bito Automatic Review Skipped - Files Excluded |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Fixes a race condition in the Docker development setup where nginx starts before the webpack dev server is ready, causing 404 errors for all static assets (
/static/assets/images/superset-logo-horiz.png, etc.).Root Cause:
When running
docker compose up, nginx starts immediately and proxies/staticrequests to port 9000. However, thesuperset-nodecontainer needs time to:npm install(can take several minutes)During this startup period, all static asset requests fail with 404 errors.
The Fix:
superset-nodethat verifies the webpack dev server is responding on port 9000depends_on: superset-node: condition: service_healthyto nginx so it waits for the frontend to be readyThe health check uses Node.js (already in the container) to make HTTP requests, with a 60-second start period and up to 30 retries at 10-second intervals (5+ minutes total wait time).
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: Static assets return 404 during startup, broken UI
After: Nginx waits for webpack dev server to be healthy before starting
TESTING INSTRUCTIONS
Clean your Docker environment:
Start fresh:
Watch the logs - you should see:
superset-noderunningnpm installand starting dev serversuperset-nodeis healthyAccess http://localhost - static assets should load correctly
ADDITIONAL INFORMATION
🤖 Generated with Claude Code