fix(ssg): clean pages/ and app/ before webstudio build to avoid stale imports#10
Closed
vianmora wants to merge 12 commits into
Closed
fix(ssg): clean pages/ and app/ before webstudio build to avoid stale imports#10vianmora wants to merge 12 commits into
vianmora wants to merge 12 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e template DOCKER_PORT_BASE env var (default 6000), dockerDomainPort map, allocateDockerPort, and DOCKER_SITE_DOCKERFILE multi-stage template (adapted from @m8jj for react-router-docker output: no .next/cache, no public/). No behaviour change — pipelines and HTTP handler untouched. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sync → build --template docker → write Dockerfile → docker build once → stop/rm/run container → prune → state.json → register all hostnames in ssrHostPort so the existing proxy serves Docker sites without changes. One image per domain, one container, all custom domains routed to same port. Uses DOCKER_BUILDKIT=1 to enable cache mounts from DOCKER_SITE_DOCKERFILE. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add stopDockerForDomain helper (stop/rm container, clean ssrHostPort + dockerDomainPort). Wire transitions in all three pipelines: ssg/ssr → docker : clean up stale output / kill subprocess before build docker → ssg : stop container + clear proxy entries docker → ssr : stop container + force clean node_modules install Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extend restoreSsrProcesses to handle mode: "docker" state.json entries. Checks if the container is running via docker inspect; restarts it if not. Reconstructs dockerDomainPort and ssrHostPort so the proxy routes correctly after a publisher container restart. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add "docker" to accepted buildMode values and dispatch to publishBuildDocker. Update file-level JSDoc. Warn at startup if Docker socket is not accessible. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add workflow, infra requirement (docker socket), port range, and BuildKit optimization notes. Add DOCKER_PORT_BASE to env var table. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the subprocess-based publishBuildSsr and installSsrDeps. The Docker pipeline (previously publishBuildDocker) is now the SSR implementation — same buildMode: "ssr" sent by the builder, no API change. Existing state.json files with mode: "ssr" are still restored at startup via the legacy subprocess path (restoreSsrProcesses); they migrate to Docker on next republish via the ssr→docker transition handler. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace host-port mapping with Docker network routing:
- Add DOCKER_NETWORK env var — shared network between publisher and site containers
- Replace dockerDomainPort/allocateDockerPort with dockerHostContainer map (hostname → containerName)
- docker run: remove -p PORT:3000, add --network=${DOCKER_NETWORK}
- Proxy: check dockerHostContainer first → proxy to containerName:3000
Legacy SSR subprocess path (ssrHostPort → 127.0.0.1) kept for existing installs
- Warn at startup if Docker socket or DOCKER_NETWORK is missing
Without this fix, the proxy returned 502 for all Docker SSR sites because
127.0.0.1:PORT is not reachable from inside the publisher container.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
apk add docker-cli installs the Docker client without the buildx plugin. With DOCKER_BUILDKIT=1, modern Docker CLI requires buildx — without it, docker build fails with 'buildx component is missing or broken'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The react-router-docker template generates a package.json with a React canary version (18.3.0-canary-...). npm strict semver rejects canary versions as satisfying >=18 peer deps, causing ERESOLVE on every build. --legacy-peer-deps bypasses this check without affecting runtime behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… 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. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Replaced by #11 |
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.
Problem
When a page is renamed or deleted in the Webstudio builder,
webstudio build --template ssgupdatesapp/__generated__/(removes the old data file, adds the new one) but leaves orphaned+Page.tsxfiles inpages/.Vite then fails during the static build because the stale
+Page.tsxstill imports the now-deleted__generated__file:Fix
Delete
pages/andapp/before eachwebstudio build --template ssgso the CLI always starts from a clean state. Thenode_modules/directory is preserved to avoid reinstalling dependencies unnecessarily.Test plan
🤖 Generated with Claude Code