From f185fac9c68ddf14dd5a0bc0579c9ba207a28f0a Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Sun, 26 Jul 2026 01:50:39 +0000 Subject: [PATCH] Bootstrap CodePress Live Dev Server recipe + dev Dockerfile Author committed Live Dev Server artifacts so previews boot from the repo instead of a runtime heuristic. - .codepress/dev-server/recipe.json: schema_version 1 with the single runnable frontend (web/, create-react-app, yarn, port 3000). - .codepress/dev-server/Dockerfile.web: thin dev-mode image that binds 0.0.0.0, installs procps, and wires HMR/bind to the runtime env contract. Pinned to node:16-bookworm because react-scripts 1.0.10 resolves to webpack 2.6.1, which hashes with md4; OpenSSL 3 (Node 17+) removed md4, so a newer base fails to start. Corepack is left disabled since the repo declares no packageManager field and yarn 1.x already ships in the base image. No staging_backend_url: the repo declares no staging/env/CI backend URL, so nothing was persisted rather than guessing. No preview-CORS edit: the Django app in server/ serves the built React bundle same-origin and has no CORS surface (no django-cors-headers, no CORS settings), and the web/ frontend makes no cross-origin API calls, so there is nothing to allow. Co-authored-by: dev@codepress.dev --- .codepress/dev-server/Dockerfile.web | 68 ++++++++++++++++++++++++++++ .codepress/dev-server/recipe.json | 22 +++++++++ 2 files changed, 90 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..e1c1c8a --- /dev/null +++ b/.codepress/dev-server/Dockerfile.web @@ -0,0 +1,68 @@ +# 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 rather than the current LTS is deliberate. web/package.json pins +# react-scripts 1.0.10, which resolves (per web/yarn.lock) to webpack 2.6.1 — +# and webpack 2/3 hash modules with md4. OpenSSL 3, bundled from Node 17 on, +# removed md4, so a newer base dies on the first build with +# `error:0308010C:digital envelope routines::unsupported`. Node 16 ships +# OpenSSL 1.1.1, so this dev server starts without patching the app. +# The FULL -bookworm variant (never -slim) supplies the node-gyp toolchain +# (make/gcc/g++/python3) that the runtime dependency install may need. +FROM public.ecr.aws/docker/library/node:16-bookworm + +# System packages the dev runtime needs. `procps` only: this app has no +# source-built native module — its single native dependency, fsevents@1.1.2, 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/* + +# Yarn 1.x ships preinstalled in the node:16 base, which is exactly the package +# manager web/yarn.lock was written by. Corepack is deliberately NOT enabled: +# this repo declares no `packageManager` field, so a corepack shim would shadow +# the working bundled yarn and try to fetch a package manager from the public +# registry on every cold start. Assert yarn is present so a base-image change +# fails loudly here at build time instead of mysteriously at dev-command time. +RUN yarn --version + +WORKDIR /app + +# THIN image: no node_modules and 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. +# HOST is CRA's own bind variable (react-scripts reads HOST, not HOSTNAME). +# BROWSER=none stops react-scripts trying to open a browser in the container. +# DANGEROUSLY_DISABLE_HOST_CHECK lets webpack-dev-server accept the preview's +# proxied Host header; without it a *.preview.codepress.dev request can be +# rejected with "Invalid Host header". Dev-only image, never a production build. +ENV HOSTNAME=0.0.0.0 \ + HOST=0.0.0.0 \ + CODEPRESS_BIND_HOST=0.0.0.0 \ + PORT=3000 \ + CODEPRESS_HMR_CLIENT_PORT=443 \ + CODEPRESS_HMR_PROTOCOL=wss \ + BROWSER=none \ + DANGEROUSLY_DISABLE_HOST_CHECK=true + +WORKDIR /app/web +EXPOSE 3000 + +# Put the checkout's bins on PATH so anything the dev command shells out to +# resolves node_modules/.bin. Populated at run time on the bind-mounted checkout +# (hydration / runtime install). Prepend, never replace ${PATH}, so the base +# image's yarn stays reachable. +ENV PATH="/app/web/node_modules/.bin:/app/node_modules/.bin:${PATH}" + +# Dev command (HMR on) — react-scripts start via the package manager, never a +# bare bin. HOST/PORT come from the env contract above. +# WDS_SOCKET_PORT is mapped from CODEPRESS_HMR_CLIENT_PORT per the runtime +# contract. Note: this pinned react-dev-utils (3.0.2) builds its HMR socket URL +# from window.location, so HMR already follows the public preview origin the way +# Next.js does, and needs no client-port flag; WDS_SOCKET_PORT is only honored by +# react-scripts >= 3.4 and is passed here for forward compatibility if the app +# is upgraded. +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..26254ec --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-26T01:48:15Z", + "discovery_branch": "codepress/dev@codepress.dev/bootstrap-dev-server-artifacts-c706f8e3", + "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": "medium" + } + ] +}