Repository navigation
feat(docker): ship the websocket server in the official image - #43437
Conversation
Step 8 of the GAQ->GTF epic: make the realtime WebSocket transport (superset-websocket) a first-class part of the official image, launchable via an alternate entrypoint, so operators no longer need a separately built image. - Dockerfile: add a superset-websocket build stage (node:24-trixie-slim) that npm-ci's, compiles the TypeScript server, and prunes to production deps. Bundle the Node runtime (copied binary + libstdc++6) plus the built server and its prod node_modules into the lean image. Only the lean lineage references the stage, so dev builds are unaffected. - docker/entrypoints/run-websocket.sh: alternate entrypoint that runs the server from the bundled Node runtime; configured via env (JWT_SECRET/JWT_COOKIE_NAME must match the app's WEBSOCKET_JWT_SECRET/WEBSOCKET_JWT_COOKIE_NAME, Redis via REDIS_*). - docker-compose-non-dev.yml: add an opt-in `superset-websocket` service (behind the `websocket` compose profile so default `up` is unchanged) that runs the official image with the ws entrypoint against the compose Redis. - docker.yml: smoke-test the bundled server on the lean image build (start it and assert GET /health), so the packaging is validated in the main image pipeline. - Docs: superset-websocket/README.md + the UPDATING.md 7.0 entry document running it from the official image; drop the stale "TODO: containerize" note.
|
Bito Automatic Review Skipped - Branch Excluded |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
/review |
Code Review Agent Run #84b786Actionable Suggestions - 0Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| COPY --from=superset-websocket --chown=superset:superset \ | ||
| /app/superset-websocket/node_modules /app/superset-websocket/node_modules | ||
| COPY --from=superset-websocket --chown=superset:superset \ | ||
| /app/superset-websocket/package.json /app/superset-websocket/package.json |
There was a problem hiding this comment.
Suggestion: The final image keeps /app as the working directory and switches to the unprivileged superset user. When LOG_TO_FILE=true and the default relative LOG_FILENAME=app.log are used, Winston attempts to create /app/app.log, but /app is not writable by superset, causing file logging to emit a permission error. Set a writable WebSocket working/log directory or use a writable absolute log path. [possible bug]
Severity Level: Minor 🧹
- ⚠️ Official-image file logging cannot create its default log file.
- ⚠️ Direct `docker run` deployments receive Winston permission errors.
- ⚠️ Compose deployments avoid this through an explicit root override.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** Dockerfile
**Line:** 280:280
**Comment:**
*Possible Bug: The final image keeps `/app` as the working directory and switches to the unprivileged `superset` user. When `LOG_TO_FILE=true` and the default relative `LOG_FILENAME=app.log` are used, Winston attempts to create `/app/app.log`, but `/app` is not writable by `superset`, causing file logging to emit a permission error. Set a writable WebSocket working/log directory or use a writable absolute log path.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Fixed in b5ec1ce. logToFile defaults to false so the default image is unaffected, but you're right that opting in with the default relative LOG_FILENAME would try to write /app/app.log, which the unprivileged superset user can't create. run-websocket.sh now cds to SUPERSET_HOME (writable: chmod 1777, owned by superset) before launching, so a relative log path lands somewhere writable. The config.json lookup is unaffected — it resolves relative to the bundle via import.meta.dirname, not the cwd.
| # Configure via environment variables (see superset-websocket/src/config.ts for | ||
| # the full set), which must match the Flask app's WEBSOCKET_* config: | ||
| # PORT, REDIS_HOST, REDIS_PORT, REDIS_PASSWORD, REDIS_SSL, | ||
| # JWT_SECRET (== WEBSOCKET_JWT_SECRET), | ||
| # JWT_COOKIE_NAME (== WEBSOCKET_JWT_COOKIE_NAME, default superset-ws-token), | ||
| # ALLOWED_ORIGINS. |
There was a problem hiding this comment.
Suggestion: The comment claims to document the full configuration surface, but it omits supported overrides including REDIS_USERNAME, LOG_TO_FILE, LOG_FILENAME, LOG_LEVEL, and the connection, timeout, buffer, and StatsD settings defined by config.ts. This gives operators an incomplete and factually incorrect configuration contract for the bundled server. [comment mismatch]
Severity Level: Minor 🧹
- ⚠️ Entrypoint comments omit supported operational configuration variables.
- ⚠️ Operators may miss Redis, logging, monitoring, or limit settings.
- ⚠️ README already points users to `src/config.ts` for the full set.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** docker/entrypoints/run-websocket.sh
**Line:** 25:30
**Comment:**
*Comment Mismatch: The comment claims to document the full configuration surface, but it omits supported overrides including `REDIS_USERNAME`, `LOG_TO_FILE`, `LOG_FILENAME`, `LOG_LEVEL`, and the connection, timeout, buffer, and StatsD settings defined by `config.ts`. This gives operators an incomplete and factually incorrect configuration contract for the bundled server.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Fixed in b5ec1ce. The comment now points to superset-websocket/src/config.ts as the authoritative, complete configuration surface (Redis, logging, connection limits, StatsD, …) instead of enumerating a partial list as if it were complete, and calls out only the values that must match the Flask app (JWT_SECRET/JWT_COOKIE_NAME and the shared Redis connection).
…modules Per review feedback: `npm run build` was transpile-only (tsc), leaving the server's imports pointing at node_modules, so the image had to ship ~30-50MB of dependencies. Switch the build to esbuild, which bundles every dependency into a single self-contained CJS file (dist/index.cjs, ~1.1MB). The runtime image now needs only the Node binary + that one file — no node_modules. - package.json: `build` -> esbuild bundle (CJS, platform=node; ws's optional native addons bufferutil/utf-8-validate marked external; import.meta.dirname defined to __dirname since the CJS output has no import.meta). Type-checking still runs via the separate `type` script (tsc --noEmit). `start` runs the bundle. - Dockerfile (main + standalone): copy only dist/ (drop the node_modules and package.json copies / `npm ci --omit=dev`). - eslint: add a proper global `ignores` so the emitted bundle in dist/ isn't linted (the block-scoped ignore didn't cover the .cjs output). Validated locally: the bundle loads and initializes with no node_modules present (reaches httpServer.listen; only blocked by the sandbox's network EPERM, not by any missing module); tsc, eslint, oxfmt, and the 46 vitest tests all pass. The lean-image /health smoke test in CI covers the real network path.
- Run the bundled server from a writable directory (SUPERSET_HOME) so opting into file logging with the default relative LOG_FILENAME (LOG_TO_FILE=true) doesn't try to write /app/app.log, which the unprivileged superset user can't create. The config.json lookup is unaffected (resolved relative to the bundle). - Correct the entrypoint's config comment: it enumerated a partial set of env vars as if complete. Point to superset-websocket/src/config.ts as the authoritative source and call out only the values that must match the Flask app (JWT_SECRET / JWT_COOKIE_NAME and the shared Redis connection).
The esbuild devDependency entries were recorded against an internal npm mirror (npm.apple.com) that CI can't reach (ENOTFOUND), failing 'npm ci'. Rewrite those 27 resolved URLs to registry.npmjs.org to match every other entry in the lockfile; the integrity hashes are unchanged (same tarballs), and 'npm ci' against the public registry verifies clean.
SUMMARY
Step 8 of the GAQ→GTF epic (targets
gaq-to-gtf): make the realtime WebSocket transport (superset-websocket) a first-class part of the official image, launchable via an alternate entrypoint — so operators no longer need a separately built image to run the realtime transport.Dockerfile: newsuperset-websocketbuild stage (node:24-trixie-slim) thatnpm cis and bundles the server with esbuild into a single self-contained file (dist/index.cjs, ~1.1MB). Theleanimage copies just the Node runtime (nodebinary +libstdc++6) and that one file — nonode_modules. Only theleanlineage references the stage, sodevbuilds are unaffected.docker/entrypoints/run-websocket.sh: alternate entrypoint running the server from the bundled runtime, configured via env (JWT_SECRET/JWT_COOKIE_NAMEmust match the app'sWEBSOCKET_JWT_SECRET/WEBSOCKET_JWT_COOKIE_NAME; Redis viaREDIS_*). Launch withdocker run <official-image> /app/docker/entrypoints/run-websocket.sh.docker-compose-non-dev.yml: opt-insuperset-websocketservice behind awebsocketcompose profile (defaultupis unchanged), running the official image with the ws entrypoint against the compose Redis.docker.yml: a smoke test on theleanbuild starts the bundled server and assertsGET /health— so the packaging is validated in the main image pipeline (runs on PRs, sinceleanis in the PR matrix).superset-websocket/README.md+ theUPDATING.md7.0 entry document running it from the official image; dropped the stale "TODO: containerize" note.The standalone
superset-websocket/Dockerfileand the existingwebsocketCI preset are left in place (dev / dedicated-image use); this PR adds the bundled-in-the-official-image path as the recommended distribution.Image size note: the
leanimage grows by the Node runtime (~40–50MB) plus the ~1.1MB bundled server (deps are inlined, so nonode_modulesis shipped). This was an explicit decision to make the transport part of the official image rather than ship a separate one.TESTING INSTRUCTIONS
leandocker build runs a new smoke test — launchesrun-websocket.shand pollsGET /health(a ≥32-byteJWT_SECRETis passed; no Redis needed for/health).docker build --target lean -t superset:ws .thendocker run --rm -p 8080:8080 -e JWT_SECRET="$(openssl rand -base64 42)" superset:ws /app/docker/entrypoints/run-websocket.shandcurl localhost:8080/health→OK.docker compose --profile websocket up superset-websocket.tsc-builds;docker-compose-non-dev.ymlpassesdocker compose config; pre-commit clean on all changed files. (The image build itself is validated by CI — no local Docker in the authoring env.)ADDITIONAL INFORMATION
WEBSOCKET_ENABLED(to use the transport)