feat(proxy): run multiple local shops in parallel behind a shared proxy#1208
feat(proxy): run multiple local shops in parallel behind a shared proxy#1208Tomasz Turkowski (tturkowski) wants to merge 5 commits into
Conversation
4f04d9f to
4b3b422
Compare
Adds `shopware-cli project proxy` (setup/up/down/list/status/verify/ teardown): a shared Traefik container routes stable hostnames like https://shop1.shopware.local to local projects, so shops publish no host ports and any number can run at once. - embedded wildcard DNS server (x/net/dns) on 127.0.0.1:53535, wired via /etc/resolver (macOS) or systemd-resolved (Linux) by a one-time `proxy setup` with a single sudo ceremony (--domain, --skip-trust) - trusted HTTPS out of the box: mkcert-compatible local CA, per-project wildcard SANs, trust-store install via smallstep/truststore - proxy mode is a marker-guarded compose.override.yaml (ports cleared with !reset, requires Compose >= 2.24); the base compose.yaml stays untouched, so `project dev` and manual docker compose keep working in both modes - `up` points APP_URL, the sales channel domain and the url keys in .shopware-project.yml at the proxy; `down` restores everything exactly - `verify` checks the whole chain bottom-up with actionable hints, including guidance when sudo is blocked or systemd-resolved is missing - docs/proxy.md explains the architecture, decisions and trade-offs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4b3b422 to
ab10413
Compare
|
Whats definitively missing here is:
|
Dev watchers through the shared proxyA quick summary of how the admin/storefront watchers can work behind the shared reverse proxy. Admin watcher — works as-is, no code changesThe admin is Vite-only. Vite works out its own HMR connection from the page it's loaded on, so all that was needed:
You open Storefront watcher (now) — webpack + a small runtime patchThe storefront's classic watcher (HMR + webpack, Rather than patching vendor file, we inject a tiny preload script when launching the watcher (Node Result: the storefront watcher runs fully through the proxy - multiple shops in parallel, clean port-free hostnames, no exposed ports, and no change to Shopware or the shop. You browse Tradeoff: it's a runtime patch — clever but hidden, and it leans on the internals of Storefront watcher (future) — Vite, the clean pathFrom 6.7.11 the storefront also ships a Vite dev server. To make that work behind a reverse proxy we need a small, fully backward-compatible contribution to
With that, the storefront watcher - once enabled, works at the shop's own URL ( Plan proposal:
|
|
btw because of excactly those REASONS I DONT WANT TO have those watchers directly inside Shopware. we're like now screwed |
What changed?
New command group
shopware-cli project proxy— run any number of local shops in parallel under stable hostnames, instead of everyone fighting over127.0.0.1:8000.proxy setup--domain,--skip-trust)proxy up/downproxy list/statusproxy verifyproxy teardownUnder the hood: one shared Traefik container routes by hostname (shops publish no host ports at all), a tiny DNS server embedded in the binary answers
*.shopware.local → 127.0.0.1, and an mkcert-compatible local CA provides trusted HTTPS. Proxy mode is a marker-guardedcompose.override.yaml— the basecompose.yamlstays untouched, soproject devand manualdocker composekeep working.uppointsAPP_URL, the sales-channel domain and the project config at the proxy;downrestores every value exactly.➡️ Architecture, design decisions and trade-offs:
docs/proxy.mdWhy?
The dev environment publishes fixed host ports, so a second shop can't start — anyone working on multiple projects juggles ports or stops shops. Routing by hostname removes the conflict by construction, and trusted HTTPS matters for testing payment providers locally.
How was this tested?
go test ./...green,golangci-lint run ./...— 0 issuesup/down/teardowncycles with byte-identical restore of.shopware-project.yml,.env.localand the sales-channel domain;verifyladder validated against a real corporate sudo-block scenarioRelated issue or discussion
Closes #1094, related: #939