Branches for every client do not scale
When a second brand launches on the same codebase, it is tempting to duplicate the repository or add if (tenant === 'brand-b') checks in components. Both shortcuts age poorly. Every bug fix has to be merged twice, and every new storefront adds another conditional branch to test.
A single-image, multi-instance architecture solves a different problem from multi-tenant shared-database SaaS. Each brand still runs its own isolated database, storage bucket, and environment, while every deployment runs the exact same container image built from one main branch.
Separate code from instance configuration
The core rule is simple: application code describes capabilities and layouts; database-backed settings describe brand identity, navigation, and enabled modules.
type StorefrontContext = {
brand: { name: string; logoUrl: string; supportPhone?: string };
capabilities: ReadonlySet<string>;
themeTokens: Record<string, string>;
};Instead of checking which domain is serving the request, UI and domain services ask whether a capability is enabled or read the active SettingsRevision. That keeps the image client-agnostic while letting a technical supply store and a boutique accessories shop look and behave differently.
Version settings instead of mutating live state
Live storefront configuration should follow the same discipline as concurrent record edits:
- Draft changes in an explicit revision rather than overwriting production keys in place.
- Validate required brand assets, payment rails, and shipping rules before publishing.
- Keep an immutable published revision so a bad layout edit can be rolled back in one step.
Keep content out of the build artifact
Marketing pages, guides, and blog posts for a specific instance belong in PostgreSQL or an admin CMS—not hardcoded as .mdx files in the shared repository. When content lives in the database, each instance owns its own editorial voice, canonical URLs, and sitemap entries without rebuilding or polluting another brand's image.
Test the contract, not the brand
When you deploy one image to multiple instances, your CI suite should verify that:
- Missing optional settings degrade cleanly without crashing SSR.
- Capability gates fail closed when a module is disabled for an instance.
- Structured data (
Organization,Product,BreadcrumbList) reads from the active brand context rather than a hardcoded fallback string.
One build artifact is only an advantage if every instance can evolve its catalog, theme, and content independently.