feat: add buildMode "docker" — one isolated container per site#8
Merged
Conversation
7011666 to
925a0de
Compare
250e560 to
5b9ce3d
Compare
… imports When a page is renamed or deleted in the builder, webstudio build --template ssg updates __generated__/ but leaves orphaned +Page.tsx files in pages/. Vite then fails to resolve the broken import from the stale page file.
IPX needs DOMAINS set to fetch assets from /cgi/image/... URLs. Without it, all /_image/ requests return 404 in Docker mode.
…containers The npm CLI generates code that installs @webstudio-is/sdk-components-react-router from the upstream registry, so the fork fix in link.tsx doesn't apply automatically. Write a patch-navlink.cjs script into the workDir before docker build. The Dockerfile runs it after npm ci (inside the build container) to patch the compiled lib/components.js before the React Router build — excluding /#section links from NavLink so they don't all get aria-current="page" in SSR.
5b9ce3d to
16a1546
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5
What this adds
A new
buildMode: "docker"forPOST /publish. Instead of running a raw Node subprocess, each site gets its own isolated Docker container. The publisher builds the image once and routes all hostnames (publish domain + custom domains) to it via the existing proxy.How it works
On publisher restart, existing Docker containers are detected via
docker inspectand restarted if stopped. Mode transitions (SSG↔Docker) clean up the previous state before building.Why this is useful for self-hosters
--restart=unless-stoppedsurvives host reboots without publisher involvementdocker psshows all sites;docker logs <name>per siteInfra requirement
The publisher container needs access to the host Docker daemon:
A warning is logged at startup if the socket is not accessible.
Bug fixes included
SSG — stale pages after rename (
fix(ssg))When a page is renamed or deleted in the builder,
webstudio build --template ssgupdates__generated__/but leaves orphaned+Page.tsxfiles inpages/. Vite then fails to resolve the broken import. Fix: cleanpages/andapp/before each build.Docker — images not loading (
fix(docker): fix IPX image loading)Two issues prevented images from loading in Docker SSR containers:
ipxFSStorage({ dir: "./public" }), butpublic/is absent from the final multi-stage image — Vite moves assets tobuild/client/at build time. The publisher patches[_image].$.tsafterwebstudio buildto use the correct path.DOMAINSallowlist to IPX blocked images served from the public builder URL (403IPX_FORBIDDEN_HOST). Fix: passIPX_HTTP_ALLOW_ALL_DOMAINS=trueto the container instead.Docker — hover styles always active on hash anchor links (
fix(docker): NavLink aria-current)In SSR, all
/#sectionlinks gotaria-current="page"because they share the pathname/with every root page.NavLinkwithend={true}still marks them all as active.The fix is in
@webstudio-is/sdk-components-react-router/src/link.tsx(fork PR pending), but the npm CLI installs the upstream package so the fix doesn't apply automatically. The publisher writes apatch-navlink.cjsscript into the workDir; the Dockerfile runs it afternpm cito patch the compiledlib/components.jsbefore the React Router build.