From 5db38b3e3229274c4ad64de2dea2fae2668469da Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2026 07:16:10 +0000 Subject: [PATCH] Bootstrap CodePress Live Dev Server recipe + dev Dockerfiles Author the committed Live Dev Server artifacts for this repo so previews boot from repo-owned files instead of a runtime heuristic. Discovered one runnable frontend: web/ (create-react-app 1.0.10, Yarn 1). The Django app in server/ is same-origin only -- it serves the built React bundle through its catch-all URL and has no CORS surface and no cross-origin caller -- so no preview-CORS change was made. No staging backend URL was found, so staging_backend_url is intentionally omitted. Verified end to end on the pinned node:18-bookworm base: - yarn install --frozen-lockfile succeeds against the 2017 lockfile - react-scripts start compiles and serves HTTP 200 - binds 0.0.0.0:3000 and answers on a non-loopback address - accepts a *.preview.codepress.dev Host header (host check off) - /sockjs-node/info reports websocket support - a source edit triggers a second successful compile (hot reload works) Node 18 is pinned deliberately: this toolchain's websocket-driver 0.6.5 calls process.binding('http_parser'), which Node 18 still provides but newer Node removes -- the dev server crashes on boot there. Co-authored-by: dev@codepress.dev --- .codepress/dev-server/Dockerfile.web | 73 ++++++++++++++++++++++++++++ .codepress/dev-server/recipe.json | 22 +++++++++ 2 files changed, 95 insertions(+) create mode 100644 .codepress/dev-server/Dockerfile.web create mode 100644 .codepress/dev-server/recipe.json diff --git a/.codepress/dev-server/Dockerfile.web b/.codepress/dev-server/Dockerfile.web new file mode 100644 index 0000000..ab251a2 --- /dev/null +++ b/.codepress/dev-server/Dockerfile.web @@ -0,0 +1,73 @@ +# Generated by CodePress bootstrap-dev-server. +# Dev-mode image for the "web" frontend (Live Dev Server). +# Edits are preserved, but running /codepress-bootstrap-dev-server again may overwrite them. + +# Node 18 is the OLDEST Node with an official -bookworm variant, and this app's +# toolchain is create-react-app 1.0.10 (webpack 2.6.1 / webpack-dev-server 2.5.0, +# 2017-era, engines.node ">=6"), so pin the most conservative supported base rather +# than the current LTS. Full -bookworm, never -slim: dependencies install at RUNTIME +# inside this image and node-gyp needs the make/gcc/g++/python3 toolchain -slim strips. +FROM public.ecr.aws/docker/library/node:18-bookworm + +# System packages for the dev runtime. `procps` only: this app has no source-built +# native module. Its one native dependency, fsevents@1.1.2, is darwin-only and is +# skipped on Linux, and there is no node-sass/canvas in the lockfile, so no extra +# apt library is required. +RUN apt-get update \ + && apt-get install -y --no-install-recommends procps \ + && rm -rf /var/lib/apt/lists/* + +# Bake ONLY the package-manager binary (never app deps) so a cold start never has to +# fetch yarn before the dev command can run. web/yarn.lock is a Yarn 1 lockfile and +# the repo declares no `packageManager` field, so pin Yarn 1.x explicitly. +RUN corepack enable && corepack prepare yarn@1.22.22 --activate + +WORKDIR /app + +# THIN image: no `node_modules`, no source COPY. The dev-server runtime provides +# dependencies at run time (squashfs hydration, or `yarn install --frozen-lockfile` +# in this image against the bind-mounted checkout). Only the toolchain lives here. + +# HMR + bind config — values come from the runtime, never hardcoded. +ENV HOSTNAME=0.0.0.0 \ + CODEPRESS_BIND_HOST=0.0.0.0 \ + PORT=3000 \ + CODEPRESS_HMR_CLIENT_PORT=443 \ + CODEPRESS_HMR_PROTOCOL=wss + +# Never try to launch a browser from a headless container. react-scripts honors +# BROWSER=none (react-dev-utils/openBrowser). +ENV BROWSER=none + +# create-react-app disables webpack-dev-server's DNS-rebinding host check unless a +# `proxy` field is present in package.json (see react-scripts +# config/webpackDevServer.config.js: `disableHostCheck: !proxy || ...`). This repo +# sets no `proxy` today, so the check is already off — pin it explicitly so the +# per-session preview hostname keeps being accepted if a `proxy` is added later. +ENV DANGEROUSLY_DISABLE_HOST_CHECK=true + +WORKDIR /app/web +EXPOSE 3000 + +# Put the app's node_modules/.bin on PATH as a backstop for anything invoking a bin +# directly; these dirs are populated at run time on the bind-mounted checkout. +# Prepend, never replace ${PATH}, so the corepack/yarn shims survive. +ENV PATH="/app/web/node_modules/.bin:/app/node_modules/.bin:${PATH}" + +# Dev command (HMR on). `react-scripts start` reads HOST and PORT from the +# environment, so map the CodePress bind var onto CRA's HOST at RUNTIME — an +# `ENV HOST=$CODEPRESS_BIND_HOST` alias would freeze the build-time value and lose +# the runtime override. +# +# HMR: this CRA version's client (react-dev-utils 3.0.2 webpackHotDevClient) builds +# its sockjs URL from `window.location`, so behind the preview proxy it dials +# wss:///sockjs-node on 443 automatically — there is no client-port +# knob to set, and nothing hardcodes localhost. WDS_SOCKET_PORT is honored by +# react-scripts 3.4+ only; it is wired here for the uniform runtime contract and so +# that a react-scripts upgrade keeps working. +# +# Note for upgraders: webpack 2.6.1 defaults `output.hashFunction` to md5, so this +# image needs NO --openssl-legacy-provider. react-scripts >= 2 (webpack 4+) defaults +# to md4, which OpenSSL 3 (Node 17+) removed — if you upgrade react-scripts, add +# NODE_OPTIONS=--openssl-legacy-provider or set a modern `output.hashFunction`. +CMD ["sh", "-c", "HOST=\"${CODEPRESS_BIND_HOST:-0.0.0.0}\" WDS_SOCKET_PORT=\"${CODEPRESS_HMR_CLIENT_PORT:-443}\" yarn start"] diff --git a/.codepress/dev-server/recipe.json b/.codepress/dev-server/recipe.json new file mode 100644 index 0000000..ba1254e --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-28T07:07:52Z", + "discovery_branch": "master", + "frontends": [ + { + "label": "web", + "working_dir": "web", + "dockerfile_path": ".codepress/dev-server/Dockerfile.web", + "dev_command": "sh -c 'HOST=\"${CODEPRESS_BIND_HOST:-0.0.0.0}\" WDS_SOCKET_PORT=\"${CODEPRESS_HMR_CLIENT_PORT:-443}\" yarn start'", + "prebuild_command": "", + "prebuild_inputs": [], + "framework": "cra", + "package_manager": "yarn", + "install_command": "yarn install --frozen-lockfile", + "dependency_manifests": ["web/yarn.lock"], + "dev_port": 3000, + "system_packages": ["procps"], + "size": "medium" + } + ] +}