From c611debbe01c481d1f0665137b76bfc7718dc997 Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:07:26 +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. Discovery found one runnable frontend, web/ (Create React App 1.0.10, yarn, dev port 3000), and one Django backend, server/. - .codepress/dev-server/recipe.json: schema_version 1 with a single "web" frontend entry. - .codepress/dev-server/Dockerfile.web: thin, dev-mode, toolchain-only image. Pins node:16-bookworm because this app is webpack 2.6.1 / webpack-dev-server 2.5.0 / React 15 and the repo pins no Node version of its own. Binds via CODEPRESS_BIND_HOST, wires HMR to the CODEPRESS_HMR_* env vars, bakes no node_modules and no source. No staging backend URL was persisted: the repo has no .env.staging, .env.example, CI workflow, or verify-staging recipe to detect one from, and the recipe must never carry a guess or a production URL. No preview-CORS edit was made. server/ configures no CORS at all and web/ makes no cross-origin API calls -- the app is same-origin by design (web/ postbuild copies the CRA build into server/static/build/ and Django serves it from a catch-all route), so there is no cross-origin surface to allow the preview origin on. 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..30a0b0c --- /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 16 is pinned deliberately. This app is Create React App 1.0.10 on +# webpack 2.6.1 / webpack-dev-server 2.5.0 / React 15 (see web/yarn.lock), a +# 2017-era toolchain that does not run on current Node majors. The repo pins no +# Node version of its own (no .nvmrc, no engines.node), so the current-LTS +# default would produce an image whose dev server never boots. +FROM public.ecr.aws/docker/library/node:16-bookworm + +# System packages the dev runtime needs. `procps` only, so dev-process +# supervisors can inspect and clean up child process trees on shutdown. This +# app's dependency tree has no native module that builds from source on linux +# (fsevents@1.1.2 is darwin-only and skipped), so no extra apt library applies. +RUN apt-get update \ + && apt-get install -y --no-install-recommends procps \ + && rm -rf /var/lib/apt/lists/* + +# yarn 1.x classic drives this app (web/yarn.lock is a v1 lockfile, and the repo +# declares no `packageManager` field). The node:16-bookworm base already ships +# yarn 1.22.x, so assert it at build time — the build then fails loudly instead +# of the dev command failing at run time — and fall back to a pinned install if a +# future base image drops it. Only the package-manager binary is baked here, +# never app dependencies. +RUN yarn --version || npm install --global --force yarn@1.22.22 + +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 + +WORKDIR /app/web +EXPOSE 3000 + +# Put the app and root bins on PATH as a backstop, so the dev command and +# anything it shells out to resolve node_modules/.bin. Both dirs are populated at +# run time on the bind-mounted checkout. Prepend, never replace ${PATH}. +ENV PATH="/app/web/node_modules/.bin:/app/node_modules/.bin:${PATH}" + +# Dev command (HMR on) — `react-scripts start`, routed through yarn rather than a +# bare bin. CRA reads HOST and PORT from env, so the bind address stays +# runtime-driven and never hardcodes localhost. WDS_SOCKET_PORT carries the +# PUBLIC HMR port for react-scripts versions that honor it; this version's +# react-dev-utils derives the sockjs URL from window.location, which already +# resolves to the preview origin behind the proxy. BROWSER=none stops CRA trying +# to launch a browser inside the container, and DANGEROUSLY_DISABLE_HOST_CHECK +# keeps webpack-dev-server from rejecting the preview's Host header. +CMD ["sh", "-c", "HOST=\"${CODEPRESS_BIND_HOST:-0.0.0.0}\" PORT=\"${PORT:-3000}\" WDS_SOCKET_PORT=\"${CODEPRESS_HMR_CLIENT_PORT:-443}\" BROWSER=none 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..9fdeb89 --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-27T16:05:25Z", + "discovery_branch": "codepress/dev@codepress.dev/bootstrap-live-dev-server-artifacts-6561aa70", + "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}\" WDS_SOCKET_PORT=\"${CODEPRESS_HMR_CLIENT_PORT:-443}\" BROWSER=none 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" + } + ] +}