From f8ae8cc1aa170214ea3cef289426d6d6a3c3df88 Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Sun, 26 Jul 2026 20:45:19 +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. Discovery found one runnable frontend (web/, Create React App via react-scripts 1.0.10, Yarn Classic, port 3000) and one backend (server/, Django 1.11 + DRF). - .codepress/dev-server/recipe.json: single "web" frontend entry. - .codepress/dev-server/Dockerfile.web: thin, toolchain-only dev image on the full node:22-bookworm base. Binds 0.0.0.0, installs procps, pins Yarn Classic via corepack, bakes no node_modules and no source. react-scripts reads the bind address from HOST rather than HOSTNAME, so the CMD maps CODEPRESS_BIND_HOST onto HOST at run time; that keeps a runtime override working instead of freezing it in at build time. No preview-CORS change: the Django app has no CORS surface and no cross-origin caller. web/'s postbuild copies the React build into server/static/build/ and Django's catch-all route renders it, so the app and API share one origin. The repo also has no staging-only config path, which would make a CORS edit report-only regardless. No staging backend URL was detected, so staging_backend_url is omitted rather than guessed. Co-authored-by: dev@codepress.dev --- .codepress/dev-server/Dockerfile.web | 59 ++++++++++++++++++++++++++++ .codepress/dev-server/recipe.json | 22 +++++++++++ 2 files changed, 81 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..6846492 --- /dev/null +++ b/.codepress/dev-server/Dockerfile.web @@ -0,0 +1,59 @@ +# 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. +FROM public.ecr.aws/docker/library/node:22-bookworm + +# System packages the dev runtime needs. `procps` only: this app's dependency tree +# has no native module that builds from source on linux (its only node-gyp package, +# `fsevents`, is darwin-only and is skipped here), 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/* + +# The repo declares no `packageManager` field and ships a v1 `web/yarn.lock`, so +# pin Yarn Classic explicitly. Baking the binary keeps cold starts from having to +# fetch a package manager off the public registry 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). 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 + +# react-scripts otherwise tries to launch a browser on start; there is none here. +ENV BROWSER=none + +# This app pins react-scripts 1.0.10, whose dev server disables webpack-dev-server's +# host check unless a `proxy` field is set in package.json. None is set today, so the +# preview host is already accepted; setting this keeps the preview working if a +# `proxy` is added later. +ENV DANGEROUSLY_DISABLE_HOST_CHECK=true + +WORKDIR /app/web +EXPOSE 3000 + +# Put the app + root bins on PATH so anything the dev command shells out to resolves +# node_modules/.bin. 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), invoked through the package manager rather than a bare bin. +# react-scripts reads the bind address from HOST (not HOSTNAME), so map +# CODEPRESS_BIND_HOST onto it at run time — that way a runtime override is honored +# instead of being frozen into an ENV at build time. +# +# WDS_SOCKET_PORT is mapped for contract uniformity, but note it is a no-op on +# react-scripts 1.x: that version's HMR client (react-dev-utils 3.x +# webpackHotDevClient) builds its SockJS URL from window.location, so behind the +# preview proxy it already connects to wss:///sockjs-node on 443. +# The mapping takes effect as written if react-scripts is later upgraded to 3.4+. +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..7517d5a --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-26T20:43:15Z", + "discovery_branch": "master", + "frontends": [ + { + "label": "web", + "working_dir": "web", + "dockerfile_path": ".codepress/dev-server/Dockerfile.web", + "dev_command": "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" + } + ] +}