From 3528603fd969873bc9fbd2268280049b7aae7786 Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 05:08:15 +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. - .codepress/dev-server/recipe.json: one frontend entry for web/ (Create React App, yarn, port 3000). - .codepress/dev-server/Dockerfile.web: thin dev-mode image on node:16-bookworm. Node 16 is deliberate — react-scripts 1.0.10 runs webpack 2.6.1, whose md4 module hashing fails on Node 17+/OpenSSL 3. Binds via CODEPRESS_BIND_HOST, bakes no node_modules or source, and maps the runtime's public HMR port into the dev command. No staging backend URL was found anywhere in the repo, so staging_backend_url is omitted rather than guessed. The Django API in server/ is left untouched: it renders the React build same-origin, ships no CORS surface, and has no staging settings path, so there is no preview-CORS change to make safely. Co-authored-by: dev@codepress.dev --- .codepress/dev-server/Dockerfile.web | 65 ++++++++++++++++++++++++++++ .codepress/dev-server/recipe.json | 22 ++++++++++ 2 files changed, 87 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..51d0a29 --- /dev/null +++ b/.codepress/dev-server/Dockerfile.web @@ -0,0 +1,65 @@ +# 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 deliberate, not stale. web/ runs Create React App 1.0.10 on webpack +# 2.6.1, which hashes modules with md4. On Node 17+ (OpenSSL 3) that throws +# "error:0308010C:digital envelope routines::unsupported" and the dev server never +# starts. Node 16 ships OpenSSL 1.1.1, so the 2017 toolchain pinned in +# web/yarn.lock compiles and hot-reloads unmodified. +# Full -bookworm, never -slim: dependencies are installed at run time, and any +# node-gyp build needs the make/gcc/g++/python3 toolchain the full base carries. +FROM public.ecr.aws/docker/library/node:16-bookworm + +# System packages beyond the base toolchain. `procps` is the baseline so dev +# process supervisors can inspect and clean up child processes during SIGTERM +# shutdown; this app's lockfile has no source-built native module that links +# against an extra system library. +RUN apt-get update \ + && apt-get install -y --no-install-recommends procps \ + && rm -rf /var/lib/apt/lists/* + +# Package manager: yarn 1 (classic) — the format web/yarn.lock is written in, and +# already bundled in the Node base image. No corepack shim is activated on +# purpose: the repo declares no `packageManager`, and an unpinned shim would try +# to fetch yarn from the public registry on every cold start. + +WORKDIR /app + +# THIN image: no baked node_modules, no source COPY. The dev-server runtime +# bind-mounts the checkout at /app and provides dependencies there (squashfs +# hydration, or `yarn install --frozen-lockfile` run in this image against the +# checkout). Only the toolchain lives in the image. + +# HMR + bind config — values come from the runtime, never hardcoded. +# HOST is CRA's spelling of the bind address (react-scripts reads process.env.HOST). +# BROWSER=none stops react-scripts from trying to launch a browser in the container. +# DANGEROUSLY_DISABLE_HOST_CHECK keeps webpack-dev-server 2.x from rejecting the +# preview hostname with "Invalid Host header". CRA already disables that check +# while web/package.json declares no `proxy` field; setting it explicitly keeps +# the preview working if a `proxy` is added later. The dev server is only +# reachable through the CodePress preview proxy, never published directly. +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 \ + CODEPRESS_BASE_PATH=/ \ + 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 can +# resolve node_modules/.bin. These 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) — must stay identical to `dev_command` in recipe.json. +# Routed through yarn rather than invoking react-scripts bare. CRA 1.x derives +# its HMR websocket URL from window.location, so it follows the public preview +# origin automatically; WDS_SOCKET_PORT is mapped from the runtime's public HMR +# port so the wiring stays correct if react-scripts is ever upgraded. +CMD ["sh", "-c", "BROWSER=none 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..599c4da --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-27T05:06:36Z", + "discovery_branch": "master", + "frontends": [ + { + "label": "web", + "working_dir": "web", + "dockerfile_path": ".codepress/dev-server/Dockerfile.web", + "dev_command": "sh -c 'BROWSER=none HOST=\"${CODEPRESS_BIND_HOST:-0.0.0.0}\" WDS_SOCKET_PORT=\"${CODEPRESS_HMR_CLIENT_PORT:-443}\" 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" + } + ] +}