fix(index-builder): run wrangler from /app/web to pick up functions/ bundle
_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 <noreply@anthropic.com>
This commit is contained in:
parent
037a04e8b5
commit
c397e66239
2 changed files with 6 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue