-
Notifications
You must be signed in to change notification settings - Fork 0
Switch OpenNext incremental cache from KV to R2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d32f8dc
71399b4
7dd232b
0fc68be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { defineCloudflareConfig } from '@opennextjs/cloudflare' | ||
| import kvIncrementalCache from '@opennextjs/cloudflare/overrides/incremental-cache/kv-incremental-cache' | ||
| import r2IncrementalCache from '@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache' | ||
|
|
||
| export default defineCloudflareConfig({ | ||
| incrementalCache: kvIncrementalCache | ||
| incrementalCache: r2IncrementalCache | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env bash | ||
| # Deploy to Cloudflare Workers using Cloudflare secrets pulled from Bitwarden. | ||
| # | ||
| # Prereqs: | ||
| # - Bitwarden CLI (`bw`) installed and logged in. | ||
| # - `jq` installed. | ||
| # - Vault unlocked: `export BW_SESSION=$(bw unlock --raw)` | ||
| # - Bitwarden item "techempower cloudflare api" (secure note) with: | ||
| # - notes -> CLOUDFLARE_API_TOKEN | ||
| # - custom "id" -> CLOUDFLARE_ACCOUNT_ID | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| ITEM_NAME="techempower cloudflare api" | ||
|
|
||
| if ! command -v bw >/dev/null 2>&1; then | ||
| echo "error: bw (Bitwarden CLI) not found on PATH" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v jq >/dev/null 2>&1; then | ||
| echo "error: jq not found on PATH" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| bw_status="$(bw status 2>/dev/null || true)" | ||
| if ! printf '%s' "$bw_status" | grep -q '"status":"unlocked"'; then | ||
| echo "error: Bitwarden vault is locked (or bw is not logged in)." >&2 | ||
| echo " run: export BW_SESSION=\$(bw unlock --raw)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| item_json="$(bw get item "$ITEM_NAME")" | ||
| CLOUDFLARE_API_TOKEN="$(printf '%s' "$item_json" | jq -r '.notes // ""')" | ||
| CLOUDFLARE_ACCOUNT_ID="$(printf '%s' "$item_json" | jq -r '.fields[]? | select(.name=="id") | .value')" | ||
|
|
||
| if [[ -z "$CLOUDFLARE_API_TOKEN" || -z "$CLOUDFLARE_ACCOUNT_ID" ]]; then | ||
| echo "error: could not read CLOUDFLARE_API_TOKEN (notes) or CLOUDFLARE_ACCOUNT_ID (custom field 'id')" >&2 | ||
| echo " from Bitwarden item '$ITEM_NAME'" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| export CLOUDFLARE_API_TOKEN | ||
| export CLOUDFLARE_ACCOUNT_ID | ||
|
|
||
| exec pnpm cf:deploy |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,12 @@ | |
| "observability": { | ||
| "enabled": true | ||
| }, | ||
| "kv_namespaces": [ | ||
| "r2_buckets": [ | ||
| { | ||
| "binding": "NEXT_INC_CACHE_KV", | ||
| "id": "77055535c51e442193e5dad69ceb5075" | ||
| // Bucket must be pre-created in the Cloudflare account before deploy: | ||
| // npx wrangler r2 bucket create techempower-cache | ||
| "binding": "NEXT_INC_CACHE_R2_BUCKET", | ||
| "bucket_name": "techempower-cache" | ||
| } | ||
|
Comment on lines
+19
to
25
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 71399b4 — added a JSONC comment on the Generated by Claude Code |
||
| ] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 71399b4 —
.github/workflows/deploy.ymlnow deploys to Cloudflare Workers viapnpm cf:deployon push tomaster/main, usingCLOUDFLARE_API_TOKEN+CLOUDFLARE_ACCOUNT_IDsecrets.package.json'sdeployscript and the hosting section ofCLAUDE.mdwere updated to match.Generated by Claude Code