From fed2991c77a14a2fef9c32e6ea391624c5f5ac17 Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Sun, 26 Jul 2026 02:01:54 +0000 Subject: [PATCH] Bootstrap CodePress Live Dev Server recipe + dev Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Author the committed Live Dev Server artifacts for this repo so previews boot from repo-owned files instead of a runtime heuristic. Discovery found exactly one runnable frontend, `web/`: a create-react-app (react-scripts 1.0.10 / webpack 2.6.1) on Yarn Classic, dev port 3000. - .codepress/dev-server/recipe.json — schema_version 1 with the single `web` frontend entry (working_dir, dev_command, framework cra, yarn, `yarn install --frozen-lockfile`, web/yarn.lock as the dependency manifest, dev_port 3000, procps). - .codepress/dev-server/Dockerfile.web — thin dev-mode image on the full node:18-bookworm ECR-public base: no baked node_modules or source, procps installed, Yarn 1 pinned via corepack, HMR/bind wired to the runtime env vars, and `react-scripts start` bound to 0.0.0.0 as the CMD. DANGEROUSLY_DISABLE_HOST_CHECK is set so webpack-dev-server 2's DNS-rebinding host check does not reject the preview hostname. No staging backend URL was detectable (single settings.py, no .env files, CI workflows, or deploy config), so `staging_backend_url` is omitted rather than guessed. The Django backend in `server/` needs no preview CORS: it has no CORS surface at all and serves the built React app same-origin. Co-authored-by: dev@codepress.dev --- .codepress/dev-server/Dockerfile.web | 58 ++++++++++++++++++++++++++++ .codepress/dev-server/recipe.json | 22 +++++++++++ 2 files changed, 80 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..8811542 --- /dev/null +++ b/.codepress/dev-server/Dockerfile.web @@ -0,0 +1,58 @@ +# 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 (FULL bookworm, never -slim): dependencies install at run time inside +# this image, so the node-gyp toolchain (make/gcc/g++/python3) has to be present. +# Nothing in the repo pins a Node version, and this frontend is a 2017-era +# create-react-app (react-scripts 1.0.10 / webpack 2.6.1), so 18 is the newest +# line that stack is comfortable on rather than the very latest LTS. webpack 2 +# hashes with md5 (not md4), so no --openssl-legacy-provider workaround is needed. +FROM public.ecr.aws/docker/library/node:18-bookworm + +# System packages the dev runtime needs. `procps` only: this app's dependency +# tree is pure JS (the single native module, fsevents, is darwin-only and is +# skipped on linux), 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/* + +# web/yarn.lock is a Yarn Classic (v1) lockfile and no `packageManager` field is +# declared, so pin Yarn 1 into the image — a cold start must never have to +# download a package manager before the dev command can run. +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). + +# 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 + +WORKDIR /app/web +EXPOSE 3000 + +# Workspace bins on PATH so the dev command — and anything it shells out to — +# resolves node_modules/.bin even when a binary is invoked 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` via the package script. +# HOST/PORT — create-react-app's bind contract, fed from the runtime env. +# BROWSER=none — nothing to open inside a container. +# WDS_SOCKET_PORT — public HMR port behind the preview proxy. react-scripts +# 1.x derives the sockjs URL from window.location (so HMR +# already works over wss:443 through the proxy) and ignores +# this; it is set for the uniform runtime contract and for +# the day this app is upgraded. +# DANGEROUSLY_DISABLE_HOST_CHECK — webpack-dev-server 2's DNS-rebinding host check +# otherwise rejects the preview hostname with "Invalid Host +# header". react-scripts 1.0.10 supports this flag. +CMD ["sh", "-c", "HOST=\"${CODEPRESS_BIND_HOST:-0.0.0.0}\" PORT=\"${PORT:-3000}\" BROWSER=none WDS_SOCKET_PORT=\"${CODEPRESS_HMR_CLIENT_PORT:-443}\" DANGEROUSLY_DISABLE_HOST_CHECK=true yarn start"] diff --git a/.codepress/dev-server/recipe.json b/.codepress/dev-server/recipe.json new file mode 100644 index 0000000..c357357 --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-26T01:53:00Z", + "discovery_branch": "codepress/dev@codepress.dev/bootstrap-live-dev-server-artifacts-866d779c", + "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}\" PORT=\"${PORT:-3000}\" BROWSER=none WDS_SOCKET_PORT=\"${CODEPRESS_HMR_CLIENT_PORT:-443}\" DANGEROUSLY_DISABLE_HOST_CHECK=true 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" + } + ] +}