Bootstrap CodePress Live Dev Server recipe + dev Dockerfile - #36
Open
codepress-dev[bot] wants to merge 1 commit into
Open
Conversation
Author the committed Live Dev Server artifacts so previews boot from repo-owned files instead of a runtime heuristic. - .codepress/dev-server/recipe.json: one frontends[] entry for web/ (Create React App 1.0.10, yarn, dev_port 3000). - .codepress/dev-server/Dockerfile.web: thin dev-mode image — binds via CODEPRESS_BIND_HOST, installs procps, bakes only the yarn binary (no node_modules, no source COPY), wires the HMR/bind env contract, and runs `yarn start`. The base is node:16-bookworm on purpose: react-scripts 1.0.10 bundles with webpack 2.6.1, which hashes with MD4. OpenSSL 3 (Node 17+) dropped MD4 from the default provider, so a current-LTS base fails immediately with `error:0308010C:digital envelope routines::unsupported`. Node 16 ships OpenSSL 1.1.1 and runs this toolchain unmodified. No staging backend URL was detected (no .env files, CI workflows, or proxy rewrites declare one), so staging_backend_url is omitted rather than guessed. No preview-CORS edit was needed: the Django API in server/ serves the React build from its own catch-all view (same-origin), carries no CORS allowlist, and has no cross-origin caller in this repo. Co-authored-by: dev@codepress.dev <dev@codepress.dev>
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.
Summary
This sets up the files CodePress needs to spin up a live, hot-reloading preview of this project's React app (
web/). Until now a preview would have had to guess how to boot the app; now the repo itself declares it, so previews start the same way every time and keep working as the project changes. Nothing about how the app runs locally or in production changes — these are new files under.codepress/dev-server/plus a preview-only Dockerfile that is never used by a real deployment. One thing worth knowing: this app is pinned to a 2017-era React toolchain (Create React App 1.0.10 / React 15), which cannot run on a current Node release without crashing on startup, so the preview image pins Node 16 to match it. Two other pieces of the bootstrap found nothing to do and made no changes: there is no staging backend URL declared anywhere in the repo to pre-fill, and the Django API here is served same-origin by design, so it needs no preview CORS allowance.Technical details
.codepress/dev-server/recipe.json— the contract the Live Dev Server reads.schema_version: 1, onefrontends[]entry:working_dir: "web",framework: "cra",package_manager: "yarn"(resolved fromweb/yarn.lock; nopackageManagerfield is declared),dev_port: 3000(CRA default — thestartscript passes no--port),install_command: "yarn install --frozen-lockfile",dependency_manifests: ["web/yarn.lock"],system_packages: ["procps"],size: "medium".dev_commandissh -c 'HOST=… PORT=… WDS_SOCKET_PORT=… BROWSER=none yarn start'— routed through yarn rather than invokingreact-scriptsbare, since the dev container's shell has nonode_modules/.binon PATH.prebuild_command/prebuild_inputsare empty:web/'sstartscript is a single command with no build prefix, nopredevhook, and no workspace sibling to build.staging_backend_urlis omitted, not empty — there is no.env*,vercel.json, CI workflow, or proxy rewrite in the repo declaring a backend URL, and the rule is never to persist a guess. The frontend-env prefill step is gated on a confident staging URL, so it was skipped too (no Live Dev Server env vars were written)..codepress/dev-server/Dockerfile.web— thin, dev-mode, toolchain-only image. NoCOPY, no bakednode_modules(the runtime bind-mounts the checkout at/appand provides deps);WORKDIR /appthen/app/web;procpsinstalled for clean dev-process shutdown;HOSTNAME/CODEPRESS_BIND_HOST/PORT/CODEPRESS_HMR_CLIENT_PORT/CODEPRESS_HMR_PROTOCOLdeclared with defaults so the runtime injects real values;CMDis the dev command, never a production build.The decision worth reviewing is
node:16-bookworminstead of the current LTS.react-scripts@1.0.10resolves towebpack@2.6.1, which hashes with MD4. OpenSSL 3 (Node 17+) removed MD4 from the default provider, so on Node 18/20/22 the dev server dies at startup witherror:0308010C:digital envelope routines::unsupported. Node 16 ships OpenSSL 1.1.1 and runs webpack 2 unmodified, which is cleaner than relying on aNODE_OPTIONS=--openssl-legacy-providerworkaround. The base is pulled frompublic.ecr.aws/docker/library/node:16-bookworm(tag confirmed present on the mirror) to avoid Docker Hub rate limits, and it is the full-bookwormimage, not-slim, so runtime native installs have the node-gyp toolchain. Ifreact-scriptsis ever upgraded, this base should be bumped — there is a comment saying so.Two supporting details: yarn is baked with
(command -v yarn || npm install -g yarn@1.22.22)so a cold start never fetches a package manager from the registry (the node base already ships yarn 1.x; the fallback covers a future base that doesn't).WDS_SOCKET_PORTis set for the uniform runtime contract but is inert onwebpack-dev-server@2.5.0, which derives its HMR socket URL fromwindow.location— that already resolves to the public preview origin behind the proxy, so HMR needs no extra wiring here.DANGEROUSLY_DISABLE_HOST_CHECK=trueandBROWSER=noneare set so the dev server accepts the proxied preview hostname and doesn't try to launch a browser in a container.No backend CORS change, deliberately. The Django app in
server/was detected, but it fails the cross-origin gate on both counts: it carries no CORS allowlist at all (django-cors-headersis not a dependency and nothing setsCORS_*), and no caller in this repo reaches it cross-origin —web/srcmakes zerofetch/XHR calls, and in productionweb/package.json'spostbuildcopies the built bundle intoserver/static/build/where Django's catch-allindexview renders it, i.e. same-origin by construction. Independently, the repo has no staging config path to scope such an edit to (a singleserver/server/settings.py, no.envfiles, no CI), so an auto-edit would have been report-only regardless.Changes
Test plan
.codepress/dev-server/recipe.jsonparses and reportsschema_version: 1with a singlewebfrontend:python3 -c "import json;print(json.load(open('.codepress/dev-server/recipe.json')))"docker build -f .codepress/dev-server/Dockerfile.web -t drx-web-dev .docker run --rm -p 3000:3000 -v "$PWD:/app" -w /app/web drx-web-dev sh -c 'yarn install --frozen-lockfile && exec sh -c "HOST=0.0.0.0 PORT=3000 BROWSER=none yarn start"'— expectCompiled successfully!and a working page at http://localhost:3000web/src/containers/home/Home.js(change theWelcome to Reactheading) and confirm the browser updates without a manual refreshnode:22-bookwormand rebuilding — the dev server should fail witherror:0308010C:digital envelope routines::unsupported, which is the reason Node 16 is pinnedwebfrontend starts from the committed recipe (dev port 3000) rather than a runtime guessOpen items
web/yarn.lock(react-scripts@1.0.10→webpack@2.6.1) rather than by a live run. The build/run steps in the test plan are the check for it.node:16-bookwormis an end-of-life Node line, chosen because the app's 2017 toolchain cannot start on a supported one. The durable fix is upgradingreact-scripts, after which this base should move to the current LTS.server/static/build/), previews will then need a staging-scoped CORS allowance for the preview origin — there is no staging settings module or.env.stagingin the repo today to put one in.Authors
Generated with CodePress · View the chat session
Co-authored-by: dev@codepress.dev dev@codepress.dev