Skip to content

feat(docker): ship the websocket server in the official image - #43437

Merged
villebro merged 4 commits into
gaq-to-gtffrom
villebro/gtf-websocket-image
Aug 23, 2026
Merged

villebro merged 4 commits into
gaq-to-gtffrom
villebro/gtf-websocket-image

Conversation

@villebro

@villebro villebro commented Aug 23, 2026 •

Copy link
Copy Markdown
Member

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: new superset-websocket build stage (node:24-trixie-slim) that npm cis and bundles the server with esbuild into a single self-contained file (dist/index.cjs, ~1.1MB). The lean image copies just the Node runtime (node binary + libstdc++6) and that one file — no node_modules. Only the lean lineage references the stage, so dev builds are unaffected.
  • docker/entrypoints/run-websocket.sh: alternate entrypoint running the server from the bundled runtime, configured via env (JWT_SECRET/JWT_COOKIE_NAME must match the app's WEBSOCKET_JWT_SECRET/WEBSOCKET_JWT_COOKIE_NAME; Redis via REDIS_*). Launch with docker run <official-image> /app/docker/entrypoints/run-websocket.sh.
  • docker-compose-non-dev.yml: opt-in superset-websocket service behind a websocket compose profile (default up is unchanged), running the official image with the ws entrypoint against the compose Redis.
  • docker.yml: a smoke test on the lean build starts the bundled server and asserts GET /health — so the packaging is validated in the main image pipeline (runs on PRs, since lean is in the PR matrix).
  • Docs: superset-websocket/README.md + the UPDATING.md 7.0 entry document running it from the official image; dropped the stale "TODO: containerize" note.

The standalone superset-websocket/Dockerfile and the existing websocket CI 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 lean image grows by the Node runtime (~40–50MB) plus the ~1.1MB bundled server (deps are inlined, so no node_modules is shipped). This was an explicit decision to make the transport part of the official image rather than ship a separate one.

TESTING INSTRUCTIONS

  • CI: the lean docker build runs a new smoke test — launches run-websocket.sh and polls GET /health (a ≥32-byte JWT_SECRET is passed; no Redis needed for /health).
  • Local: docker build --target lean -t superset:ws . then docker run --rm -p 8080:8080 -e JWT_SECRET="$(openssl rand -base64 42)" superset:ws /app/docker/entrypoints/run-websocket.sh and curl localhost:8080/health → OK.
  • Compose: docker compose --profile websocket up superset-websocket.
  • Verified locally: the ws server still tsc-builds; docker-compose-non-dev.yml passes docker 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

  • Has associated issue:
  • Required feature flags: WEBSOCKET_ENABLED (to use the transport)
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

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-code-review

bito-code-review Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at [email protected].

@github-actions github-actions Bot added the github_actions Pull requests that update GitHub Actions code label Aug 23, 2026
@netlify

netlify Bot commented Aug 23, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 5cd92b7
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a8b43dcc87af700071c117d
😎 Deploy Preview https://deploy-preview-43437--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@villebro

Copy link
Copy Markdown
Member Author

/review

@bito-code-review

bito-code-review Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #84b786

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • Dockerfile - 1
Review Details
  • Files reviewed - 2 · Commit Range: 5cd92b7..5cd92b7
    • Dockerfile
    • docker/entrypoints/run-websocket.sh
  • Files skipped - 4
    • .github/workflows/docker.yml - Reason: Filter setting
    • UPDATING.md - Reason: Filter setting
    • docker-compose-non-dev.yml - Reason: Filter setting
    • superset-websocket/README.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread Dockerfile Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Use CodeAnt Skill

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 fix
👍 | 👎

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docker/entrypoints/run-websocket.sh Outdated
Comment on lines +25 to +30
# 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Use CodeAnt Skill

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 fix
👍 | 👎

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@villebro
villebro merged commit b92e97b into gaq-to-gtf Aug 23, 2026
58 checks passed
@villebro
villebro deleted the villebro/gtf-websocket-image branch August 23, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies:npm github_actions Pull requests that update GitHub Actions code infra:container Infra container and K8s size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant