From 3d0c01806a08a28c3dad313482706e48c0773c4b Mon Sep 17 00:00:00 2001 From: gmalbert Date: Tue, 6 Oct 2026 16:59:59 -0400 Subject: [PATCH 1/4] Build: add Cloudflare Pages API proxy for parity frontend --- .../frontend/functions/api/[[path]].js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 fastapi_react/frontend/functions/api/[[path]].js diff --git a/fastapi_react/frontend/functions/api/[[path]].js b/fastapi_react/frontend/functions/api/[[path]].js new file mode 100644 index 00000000..d30e4ee2 --- /dev/null +++ b/fastapi_react/frontend/functions/api/[[path]].js @@ -0,0 +1,29 @@ +export async function onRequest({ request, env }) { + if (!env.F1_API_ORIGIN) { + return new Response("API origin is not configured", { status: 503 }); + } + + let apiUrl; + try { + apiUrl = new URL(env.F1_API_ORIGIN); + } catch { + return new Response("API origin is invalid", { status: 500 }); + } + + if ( + apiUrl.protocol !== "https:" || + apiUrl.pathname !== "/" || + apiUrl.search || + apiUrl.hash || + apiUrl.username || + apiUrl.password + ) { + return new Response("API origin must be an HTTPS origin", { status: 500 }); + } + + const incomingUrl = new URL(request.url); + apiUrl.pathname = incomingUrl.pathname; + apiUrl.search = incomingUrl.search; + + return fetch(new Request(apiUrl, request)); +} From 6a05b507c7c80a8e9b4c826d494c2e671937e193 Mon Sep 17 00:00:00 2001 From: gmalbert Date: Tue, 6 Oct 2026 17:02:51 -0400 Subject: [PATCH 2/4] fix: align backend image with repository layout Run the API from its package directory so app.main imports resolve while the Git checkout is mounted read-only at /repo. --- fastapi_react/backend/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastapi_react/backend/Dockerfile b/fastapi_react/backend/Dockerfile index 7e86be3a..48d04fda 100644 --- a/fastapi_react/backend/Dockerfile +++ b/fastapi_react/backend/Dockerfile @@ -10,11 +10,11 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 && rm -rf /var/lib/apt/lists/* -WORKDIR /app +WORKDIR /app/fastapi_react/backend COPY fastapi_react/backend/requirements.txt /tmp/requirements.txt RUN pip install --no-cache-dir -r /tmp/requirements.txt -COPY fastapi_react/backend/app /app/app +COPY fastapi_react/backend/app /app/fastapi_react/backend/app EXPOSE 8000 CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"] From c1439c2bc852f840852c2234ce6428959b3c4448 Mon Sep 17 00:00:00 2001 From: gmalbert Date: Tue, 6 Oct 2026 17:02:59 -0400 Subject: [PATCH 3/4] build: exclude Git and local runtime caches from Docker context --- .dockerignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..fb39adcd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +.git +.venv/ +venv/ +**/.venv/ +**/venv/ +node_modules/ +**/node_modules/ +__pycache__/ +**/__pycache__/ +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ +catboost_info/ +data_files/f1_cache/ +**/f1_cache/ From a18718354d4bcfd69253a79915d6b1ec71934817 Mon Sep 17 00:00:00 2001 From: gmalbert Date: Tue, 6 Oct 2026 17:03:07 -0400 Subject: [PATCH 4/4] deploy: add localhost-only production API Compose service The container reads application data from the read-only Git checkout, stays bound to loopback for Cloudflare Tunnel access, and restarts automatically. --- fastapi_react/docker-compose.prod.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 fastapi_react/docker-compose.prod.yml diff --git a/fastapi_react/docker-compose.prod.yml b/fastapi_react/docker-compose.prod.yml new file mode 100644 index 00000000..3eaaca54 --- /dev/null +++ b/fastapi_react/docker-compose.prod.yml @@ -0,0 +1,19 @@ +services: + backend: + build: + context: .. + dockerfile: fastapi_react/backend/Dockerfile + environment: + F1_REPO_ROOT: /repo + F1_TRUSTED_LOCAL: "0" + ENABLE_EXPENSIVE_TOOLS: "0" + OMP_NUM_THREADS: "1" + OPENBLAS_NUM_THREADS: "1" + MKL_NUM_THREADS: "1" + NUMEXPR_NUM_THREADS: "1" + volumes: + - ..:/repo:ro + ports: + - "127.0.0.1:8000:8000" + restart: unless-stopped + mem_limit: 1600m