From f2cbdcf525de0cfa09e2c34ac70a88ec05466d60 Mon Sep 17 00:00:00 2001 From: "codepress-dev[bot]" <202219725+codepress-dev[bot]@users.noreply.github.com> Date: Sat, 25 Jul 2026 19:13:26 +0000 Subject: [PATCH] Bootstrap CodePress Live Dev Server recipe + dev Dockerfile 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 on yarn classic) and one backend (server/, Django 1.11). The Django app serves the React bundle same-origin through its catch-all index view and carries no CORS surface, so no preview-CORS edit applies here. No staging backend URL exists anywhere in the repo, so staging_backend_url is deliberately omitted rather than guessed. The dev image pins Node 18 with --openssl-legacy-provider because webpack 2.6.1 predates OpenSSL 3, and sets DANGEROUSLY_DISABLE_HOST_CHECK so webpack-dev-server answers requests addressed to the preview hostname. Co-authored-by: dev@codepress.dev --- .codepress/dev-server/Dockerfile.web | 61 ++++++++++++++++++++++++++++ .codepress/dev-server/recipe.json | 22 ++++++++++ 2 files changed, 83 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..f2a673d --- /dev/null +++ b/.codepress/dev-server/Dockerfile.web @@ -0,0 +1,61 @@ +# 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 rather than the current LTS is deliberate. This app is Create React +# App 1.0.10 on webpack 2.6.1, a pipeline that predates OpenSSL 3 and relies on +# md4 hashing; it runs on Node 18 with --openssl-legacy-provider (set below), +# and newer Node majors have dropped that escape hatch. +FROM public.ecr.aws/docker/library/node:18-bookworm + +# System packages the dev runtime needs. `procps` only: this app builds no +# native module from source (its one native dep, fsevents, is optional and +# darwin-only, so it is skipped on linux). The node-gyp toolchain +# (make/gcc/g++/python3) comes from the full -bookworm base. +RUN apt-get update \ + && apt-get install -y --no-install-recommends procps \ + && rm -rf /var/lib/apt/lists/* + +# Bake the package manager so a cold start never has to fetch it. web/yarn.lock +# is a Yarn v1 lockfile and the repo declares no `packageManager`, so pin Yarn +# Classic explicitly. This bakes only the yarn binary, not app dependencies. +RUN corepack enable && corepack prepare yarn@1.22.22 --activate + +WORKDIR /app + +# THIN image: no `node_modules` and no source COPY. The dev-server runtime +# provides dependencies at run time against the bind-mounted checkout at /app +# (squashfs hydration, or `yarn install --frozen-lockfile` in this image). + +# HMR + bind config. Values come from the runtime; nothing here is hardcoded to +# localhost. BROWSER=none stops react-scripts from trying to open a browser in +# the container, and DANGEROUSLY_DISABLE_HOST_CHECK lets webpack-dev-server +# answer requests addressed to the preview hostname instead of rejecting them +# with "Invalid Host header" (the CRA equivalent of Vite's allowedHosts). +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 \ + NODE_OPTIONS=--openssl-legacy-provider + +WORKDIR /app/web +EXPOSE 3000 + +# Put the app's bins on PATH so the dev command — and anything it shells out to +# — resolves node_modules/.bin. These dirs are populated at run time on the +# bind-mounted checkout. Prepend, never replace, 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` reads HOST and PORT from env, so +# bind is covered by the runtime contract. This CRA version's HMR client +# (react-dev-utils 3) opens its sockjs connection against the page's own origin, +# so it works through the preview proxy without a client-port flag once +# websocket upgrades are forwarded; WDS_SOCKET_PORT is mapped anyway to keep the +# runtime contract uniform and to stay correct if CRA is ever 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..b59d139 --- /dev/null +++ b/.codepress/dev-server/recipe.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "bootstrapped_at": "2026-07-25T19:11:56Z", + "discovery_branch": "codepress/dev@codepress.dev/bootstrap-live-dev-server-artifacts-eeb2df86", + "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}\" 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": "small" + } + ] +}