Skip to content

fix(dashboard): pass NEXT_PUBLIC_AFFILIATES_ENABLED into Docker build - #742

Merged
unjica merged 2 commits into
developfrom
fix/dashboard-next-public-build-args
Oct 6, 2026
Merged

unjica merged 2 commits into
developfrom
fix/dashboard-next-public-build-args

Conversation

@unjica

@unjica unjica commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Base branch: develop.

Summary

Next.js inlines NEXT_PUBLIC_* into the bundle at next build. Railway only forwards service variables into a Dockerfile build when they are declared as ARG, and the root Dockerfile declared none, so no dashboard NEXT_PUBLIC_* value ever reached the build (verified on prod bundles: env.NEXT_PUBLIC_* references are left un-inlined). For affiliates this means the client-side ReferralCapture (/?ref=<code>) could never activate even after setting NEXT_PUBLIC_AFFILIATES_ENABLED=true.

  • Dockerfile (build stage, before pnpm --filter dashboard build): ARG NEXT_PUBLIC_AFFILIATES_ENABLED + ENV NEXT_PUBLIC_AFFILIATES_ENABLED=$NEXT_PUBLIC_AFFILIATES_ENABLED.
  • Scope is only the affiliates flag. Other NEXT_PUBLIC_* (Sentry / telemetry) intentionally not added — that would change prod behavior and is a separate decision.
  • docs/AFFILIATES.md: the dashboard flag is build-time; changing it requires a dashboard rebuild, not a cached-image redeploy.
  • CHANGELOG.md [Unreleased] entry.

Unset behavior: the variable is not set on the Railway dashboard service today, so the ARG is empty → "" is inlined → "" !== "true" → flag OFF, same as today. The ENV lives only in the build stage (runner stage starts FROM base).

How to test

  • hadolint Dockerfile → only the pre-existing DL3008 warning (identical to develop).
  • CI build.
  • After release: the dashboard deploy succeeds and behavior is unchanged (flag still unset). Enabling later = set NEXT_PUBLIC_AFFILIATES_ENABLED=true on the dashboard service (Railway rebuilds) → /?ref=<code> writes sessionStorage tt_affiliate_ref.

Code review (Bugbot)

Paused: GitHub bugbot-review is currently a no-op.

Checklist

  • Lint passes (Dockerfile linted; no app code changed)
  • CHANGELOG.md updated under [Unreleased]
  • Documentation updated
  • No breaking changes

Security / privacy

N/A — a boolean public flag only; no secrets passed as build args.

unjica added 2 commits October 6, 2026 09:34
Next.js inlines NEXT_PUBLIC_* at next build, and Railway only forwards
service variables into Dockerfile builds when declared as ARG. Without
this, the client-side ?ref= capture can never see the flag. Unset ARG
keeps the flag off (unchanged behavior). Document that changing the flag
requires a dashboard rebuild.
@unjica
unjica merged commit f614d22 into develop Oct 6, 2026
7 checks passed
@unjica unjica mentioned this pull request Oct 6, 2026
4 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant