From c397e6623909e6e9706b9be3d7f0a046493ffb76 Mon Sep 17 00:00:00 2001 From: jedarden Date: Thu, 30 Apr 2026 12:39:57 -0400 Subject: [PATCH] fix(index-builder): run wrangler from /app/web to pick up functions/ bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _worker.js static file approach fails — Cloudflare rejects it when uploaded as a static asset. Instead, copy web/functions/ into the image and set wrangler CWD to /app/web/ so it discovers functions/ and uploads the Pages Functions bundle correctly on every deploy cycle. Co-Authored-By: Claude Sonnet 4.6 --- cmd/acb-index-builder/Dockerfile | 5 ++--- cmd/acb-index-builder/deploy.go | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/acb-index-builder/Dockerfile b/cmd/acb-index-builder/Dockerfile index a9cd4ed..de78c0c 100644 --- a/cmd/acb-index-builder/Dockerfile +++ b/cmd/acb-index-builder/Dockerfile @@ -5,9 +5,6 @@ COPY web/package.json web/package-lock.json ./ RUN npm ci COPY web/ . RUN npm run build -# Bundle Pages Functions (functions/ dir) into dist/_worker.js so the -# wrangler deploy from the index-builder runtime includes the R2 proxy function. -RUN npx wrangler pages functions build --outfile dist/_worker.js # Go binary build stage FROM golang:1.25-alpine AS builder @@ -51,6 +48,8 @@ COPY --from=builder /acb-index-builder /usr/local/bin/acb-index-builder # Copy pre-built web frontend COPY --from=web-builder /web/dist /app/web/dist +# Copy Pages Functions so wrangler can discover them at deploy time +COPY --from=web-builder /web/functions /app/web/functions # Create data directory RUN mkdir -p /data diff --git a/cmd/acb-index-builder/deploy.go b/cmd/acb-index-builder/deploy.go index 2ea0835..5f353dd 100644 --- a/cmd/acb-index-builder/deploy.go +++ b/cmd/acb-index-builder/deploy.go @@ -145,7 +145,10 @@ func deployToPages(cfg *Config) error { cmd := exec.CommandContext(ctx, "wrangler", args...) cmd.Env = env - cmd.Dir = "/tmp" // wrangler creates .wrangler/tmp relative to CWD; /app is root-owned + // Run from /app/web so wrangler discovers /app/web/functions/ and uploads it as + // the Pages Functions bundle. /tmp was the old CWD but it has no functions/ dir, + // causing every deploy to strip the R2 proxy function from the production site. + cmd.Dir = "/app/web" cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr