Bootstrap CodePress Live Dev Server recipe + dev Dockerfile - #40
Open
codepress-dev[bot] wants to merge 1 commit into
Open
Conversation
Author the committed Live Dev Server artifacts for this repo: - .codepress/dev-server/recipe.json (schema_version 1) with one frontends[] entry for the CRA app in web/ (yarn, port 3000, procps). - .codepress/dev-server/Dockerfile.web: thin, dev-mode image on the full node:18-bookworm base. Binds 0.0.0.0 via CODEPRESS_BIND_HOST, wires HMR to the CODEPRESS_HMR_* env vars, bakes no node_modules/source and no CodePress binary. Node 18 + --openssl-legacy-provider because web/ pins react-scripts 1.0.10 (webpack 2.6.1, md4 hashing). No staging backend URL was confidently detected (no .env files, CI workflows, or rewrites), so staging_backend_url is omitted. The Django app in server/ carries no CORS surface (no django-cors-headers, no allowlist; it serves the built React bundle same-origin) and the repo has no staging config path, so no preview-CORS edit was made. 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 run a live, hot-reloading preview of this project's React app. Until now the preview would have had to guess how to start the app; now the repo itself declares it, so previews boot the same way every time and the setup is reviewable and editable in git. The only runnable frontend here is the Create React App in
web/, so there is one recipe entry and one preview image for it. Two things intentionally were not set up, because doing so safely wasn't possible from what's in the repo: no staging backend URL could be confidently detected (there are no environment files, CI workflows, or proxy rewrites naming one), and the Django API inserver/was left untouched — it has no cross-origin (CORS) setup at all today and serves the built React bundle itself, and the repo has no staging-only config to scope such a change to. Both are explained under Open items.Technical details
.codepress/dev-server/recipe.json—schema_version: 1, onefrontends[]entry:label: web,working_dir: web,framework: cra,package_manager: yarn,install_command: yarn install --frozen-lockfile,dependency_manifests: ["web/yarn.lock"],dev_port: 3000,system_packages: ["procps"],size: small.staging_backend_urlis omitted rather than guessed. Noprebuild_command—web/package.jsonhas nopredev/&&-chained dev script and no workspace package to build first..codepress/dev-server/Dockerfile.web— thin, toolchain-only dev image: fullnode:18-bookworm(from the public-ECR mirror),procps,corepack enable,WORKDIR /app→/app/web, nonode_modulesbaked, no sourceCOPY, no CodePress binary. Bind and HMR come fromCODEPRESS_BIND_HOST/PORT/CODEPRESS_HMR_CLIENT_PORT/CODEPRESS_HMR_PROTOCOL; nothing hardcodeslocalhost.CMDisyarn start(react-scripts start), i.e. dev mode with HMR — never a production build.Two decisions worth a look, both forced by the age of the toolchain (
react-scripts@1.0.10/webpack@2.6.1, verified fromweb/yarn.lock):NODE_OPTIONS=--openssl-legacy-provideris set and the base image is pinned to the oldest Node LTS available as abookwormimage. Newer Node would crash the dev server on startup.react-dev-utils@3.0.2'swebpackHotDevClientbuilds its sockjs URL fromwindow.location(protocol/hostname/port) with path/sockjs-node, so the browser already targets the public preview origin.WDS_SOCKET_PORTis still exported fromCODEPRESS_HMR_CLIENT_PORTfor contract uniformity (this version ignores it; newer react-scripts reads it).DANGEROUSLY_DISABLE_HOST_CHECK=trueandBROWSER=noneare set: webpack-dev-server 2.x's host check is already inert in this app (disableHostCheck: !proxyandweb/package.jsondeclares noproxy), so this is defensive against aproxyfield being added later, which would otherwise make previews fail with "Invalid Host header".samples/auth-web/(which contains a GitHub OAuth button) was evaluated for the preview social-auth pass and excluded: it has nopackage.jsonand its imports (../../redux/auth,../../../config/settings) don't resolve anywhere in this repo — it's reference code, not part of the runnableweb/app, whose router renders onlyHome. No auth files were changed.Changes
Test plan
docker build -f .codepress/dev-server/Dockerfile.web -t drx-web-dev .— it should succeed without installing dependencies (thin image).docker run --rm -p 3000:3000 -v "$PWD:/app" -w /app/web drx-web-dev sh -c 'yarn install --frozen-lockfile && export HOST=0.0.0.0 PORT=3000 BROWSER=none NODE_OPTIONS=--openssl-legacy-provider && yarn start'— the dev server should compile and log that it is listening on 0.0.0.0:3000 (no OpenSSLdigital envelope routines::unsupportederror).web/src/containers/home/Home.js(change a visible string) and confirm the browser updates without a manual reload — HMR is live.webfrontend from the recipe and the page loads at the preview URL.Open items
Authors
Generated with CodePress · View the chat session
Co-authored-by: dev@codepress.dev dev@codepress.dev