Multi-Brand Application Delivery

The Challenge

A white-label healthcare platform supports 4+ brands across multiple environments (dev, staging, production). The old build system compiled brand identity into the Flutter web app at build time using 5 shell scripts (~650 lines of bash) that copied brand assets, merged locale files, and injected configuration via sed/awk text processing. This meant:

Approach & Role

I designed and implemented a complete architectural replacement: a single Docker image that resolves brand identity and deployment configuration at container startup through environment variables. The Flutter app compiles once with placeholder tokens, and a Go entrypoint fills in the blanks in ~200ms before handing off to Nginx.

The core insight: Flutter web compiles to JavaScript, and String.fromEnvironment resolves at compile time - there's no way to read environment variables from a browser at runtime. So we compile with deterministic placeholder tokens, then replace them in the generated JavaScript files before serving. This gives us runtime configurability without losing Flutter's compilation model.

Architecture & Patterns

Build-time tokenization (tokenize-locale, 276 lines of Go):

Runtime brand resolution (entrypoint, 1,000 lines of Go):

Healthcheck (healthcheck, 65 lines of Go):

4-stage Dockerfile:

  1. Go build - compiles entrypoint, healthcheck, and tokenize-locale to static binaries (CGO_ENABLED=0)
  2. Flutter build - installs SDK (pinned version + SHA256 verification), tokenizes locales, generates l10n, runs build_runner, then builds with placeholder --dart-define values
  3. App assembly - combines Go binaries, Flutter output, brand assets, base locales, and config into a clean filesystem layout
  4. Runtime - Chainguard Nginx or customized Azure Linux based FIPS + Nginx, runs as non-root (UID 65532), healthcheck configured

Security considerations:

CI/CD simplification:

Impact & Scale