fix(docker): prevent static asset 404s by waiting for webpack dev server

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>
This commit is contained in:
Evan Rusackas
2026-02-21 21:51:14 -08:00
parent a87a006aae
commit e4f0e0a71b

View File

@@ -61,6 +61,9 @@ services:
volumes:
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/nginx/templates:/etc/nginx/templates:ro
depends_on:
superset-node:
condition: service_healthy
redis:
image: redis:7
@@ -186,6 +189,14 @@ services:
- path: docker/.env-local # optional override
required: false
volumes: *superset-volumes
healthcheck:
# Check if webpack dev server is responding on port 9000
# This prevents nginx from proxying before the frontend is ready
test: ["CMD-SHELL", "node -e \"const http = require('http'); http.get('http://localhost:9000', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))\""]
interval: 10s
timeout: 5s
retries: 30
start_period: 60s
superset-worker:
build: