From bb3086a2cecd1f73c3d50297ca83bd1a42547571 Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Tue, 28 Jul 2026 05:12:43 +0000 Subject: [PATCH] Bootstrap CodePress Live Dev Server recipe + dev Dockerfiles Author the committed Live Dev Server artifacts so previews boot from repo-owned files instead of a runtime heuristic. Discovered one runnable frontend: the create-react-app app in web/ (react-scripts 1.0.10 / webpack 2.6.1, yarn classic lockfile). Dockerfile.web pins node:18-bookworm -- the oldest Debian-bookworm Node image and the closest match to this 2017-era toolchain. Verified on Node 18.20 / OpenSSL 3 that the app installs with `yarn install --frozen-lockfile`, boots, binds 0.0.0.0, serves HTTP 200 under a preview Host header, and exposes a live /sockjs-node HMR endpoint. Notes on deliberate choices: - No --openssl-legacy-provider: webpack 2 hashes with md5, not md4, so OpenSSL 3 does not break it (confirmed by running the dev server). - Corepack is not enabled: the repo declares no `packageManager`, so a corepack shim would try to fetch yarn from the network on cold start. - No HMR client-port wiring needed: react-dev-utils 3.0.2 builds its SockJS URL from window.location, so it follows the preview origin. No backend CORS change: the Django API in server/ is same-origin only (web/ makes no API calls and its build is served by Django), and the repo has no staging config path to scope an allowance to. Co-authored-by: dev@codepress.dev --- .codepress/dev-server/Dockerfile.web | 62 ++++++++++++++++++++++++++++ .codepress/dev-server/recipe.json | 22 ++++++++++ 2 files changed, 84 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..fe3c7d3 --- /dev/null +++ b/.codepress/dev-server/Dockerfile.web @@ -0,0 +1,62 @@ +# 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 Debian-bookworm Node image and the closest match to this +# app's 2017-era toolchain (react-scripts 1.0.10 / webpack 2.6.1); newer majors +# drift further from what this dependency tree was built against. Verified: the +# app installs and serves on Node 18.20 / OpenSSL 3. Use the FULL -bookworm +# image, never -slim -- dependencies install at run time and need node-gyp's +# build toolchain. +FROM public.ecr.aws/docker/library/node:18-bookworm + +# `procps` only: nothing in this dependency tree builds from source against a +# system library (its one native package, fsevents, is darwin-only and is +# skipped on linux). procps gives dev-process supervisors `ps` for clean +# shutdown in direct MicroVM runtimes. +RUN apt-get update \ + && apt-get install -y --no-install-recommends procps \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +# Package manager: yarn 1 (classic), which ships preinstalled in the node image +# and matches this repo's `yarn lockfile v1`. Corepack is deliberately NOT +# enabled: the repo declares no `packageManager`, so a corepack shim would try +# to fetch a yarn release from the network on first run and can fail a cold +# start for no benefit. + +# THIN image: no node_modules, no source COPY. The dev-server runtime provides +# dependencies at run time (squashfs hydration, or `yarn install` in this image +# against the bind-mounted checkout). + +# 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 open a browser inside the container. +ENV BROWSER=none + +# webpack-dev-server 2.5.0 answers unknown Host headers with "Invalid Host +# header". react-scripts skips that check only while no `proxy` is configured +# in web/package.json -- true today, but set the flag explicitly so a preview +# served from an arbitrary *.preview.codepress.dev host keeps working if a +# `proxy` is ever added. +ENV DANGEROUSLY_DISABLE_HOST_CHECK=true + +WORKDIR /app/web +EXPOSE 3000 + +# Backstop so the dev command resolves node_modules/.bin even when a bin is +# invoked directly. Populated at run time on the bind-mounted checkout. +ENV PATH="/app/web/node_modules/.bin:/app/node_modules/.bin:${PATH}" + +# Dev command (HMR on). react-scripts 1.0.10 reads HOST and PORT from env. +# HMR needs no client-port flag here: react-dev-utils 3.0.2's hot client builds +# its SockJS URL from window.location, so it follows the preview origin (wss on +# 443) by itself. WDS_SOCKET_PORT is inert on this pinned version and only takes +# effect if react-scripts is ever upgraded to >= 3.4. +CMD ["sh", "-c", "HOST=\"$CODEPRESS_BIND_HOST\" WDS_SOCKET_PORT=\"$CODEPRESS_HMR_CLIENT_PORT\" yarn start"] diff --git a/.codepress/dev-server/recipe.json b/.codepress/dev-server/recipe.json new file mode 100644 index 0000000..6feb425 --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-28T05:10:23Z", + "discovery_branch": "master", + "frontends": [ + { + "label": "web", + "working_dir": "web", + "dockerfile_path": ".codepress/dev-server/Dockerfile.web", + "dev_command": "sh -c 'HOST=\"$CODEPRESS_BIND_HOST\" WDS_SOCKET_PORT=\"$CODEPRESS_HMR_CLIENT_PORT\" 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": "small" + } + ] +}