Skip to content
Merged

Dev #51

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,26 @@ Warning:

Rebase currently supports two production paths for media uploads:

1. preferred long-term: set `R2_ACCESS_KEY_ID` and `R2_SECRET_ACCESS_KEY`
2. fallback used for the first rollout: mount a logged-in Wrangler profile and set `R2_DEV_USE_WRANGLER=true`
1. current production path: set `R2_ACCESS_KEY_ID` and `R2_SECRET_ACCESS_KEY`
2. fallback-only path: mount a logged-in Wrangler profile and set `R2_DEV_USE_WRANGLER=true`

Production now runs on the first path. The API has been verified in `r2-s3` mode against bucket `rebase-media` with a successful `HeadBucket`, `PutObject`, and `DeleteObject` round trip.

Canonical public media host:

- `https://media.rebase.network`
- alternate public host: `https://media.rebase.community`

Recommended production env:

```env
R2_ACCOUNT_ID=7e327cb72b95b88c927c7122db11baa6
R2_ACCESS_KEY_ID=...
R2_SECRET_ACCESS_KEY=...
R2_BUCKET=rebase-media
R2_PUBLIC_BASE_URL=https://media.rebase.network
R2_DEV_USE_WRANGLER=false
```

The fallback path is useful when the bucket already exists but dedicated S3 credentials have not been issued yet. In that mode:

Expand All @@ -305,6 +323,12 @@ scp ~/Library/Preferences/.wrangler/config/default.toml rebase@101.33.75.240:/ho

Wrangler can then refresh the OAuth session as needed while the API shells out for uploads.

Troubleshooting notes from production rollout:

- if upload requests return `500` while the API is in `wrangler-cli` mode, verify the container can resolve the `wrangler` executable
- if upload requests return `401` while the API is in `r2-s3` mode, verify `R2_ACCOUNT_ID`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, and the bucket-scoped `Object Read & Write` permissions
- if the API image build fails on `COPY geekdaily.csv`, remove that dependency from the Docker image build because `geekdaily.csv` is ignored by git and is not part of the release artifact set

## Verification Checklist

After deployment, verify:
Expand All @@ -316,6 +340,7 @@ After deployment, verify:
- `https://admin.rebase.network`
- homepage, GeekDaily list, article list, events list, and hiring list
- admin login and one content edit round trip
- one admin media upload round trip

## Operational Notes

Expand Down
14 changes: 11 additions & 3 deletions docs/production-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,24 @@ Use `infra/production/server.env.example` as the committed template.

### R2-related values

Current production state:

- media uploads use `r2-s3`
- bucket: `rebase-media`
- canonical public base URL: `https://media.rebase.network`
- alternate public media host: `https://media.rebase.community`
- Wrangler-backed upload is retained only as an emergency fallback, not the normal production path

| Variable | Purpose | Secret | Location |
| --- | --- | --- | --- |
| `R2_ACCOUNT_ID` | Cloudflare account target for R2 | no | remote env |
| `R2_ACCESS_KEY_ID` | direct S3-style access key | yes | remote env |
| `R2_SECRET_ACCESS_KEY` | direct S3-style secret key | yes | remote env |
| `R2_BUCKET` | media bucket name, currently `rebase-media` | no | remote env |
| `R2_PUBLIC_BASE_URL` | public media base URL | no | remote env |
| `R2_DEV_USE_WRANGLER` | fallback Wrangler-based upload mode | no | remote env |
| `CLOUDFLARE_API_TOKEN` | fallback CLI-based upload token | yes | remote env |
| `WRANGLER_CONFIG_DIR` | mounted Wrangler profile path | no | remote env |
| `R2_DEV_USE_WRANGLER` | fallback Wrangler-based upload mode, keep `false` in normal production | no | remote env |
| `CLOUDFLARE_API_TOKEN` | optional fallback CLI-based upload token | yes | remote env |
| `WRANGLER_CONFIG_DIR` | optional mounted Wrangler profile path for fallback mode | no | remote env |

## Operations Entry Points

Expand Down
22 changes: 22 additions & 0 deletions skills/rebase-api-rollout/references/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ If `https://api.rebase.network` fails but local health is good, inspect:
- tunnel token in `infra/production/server.env`
- Cloudflare Zero Trust hostname mapping

## R2 Upload Fails

Check these in order:

1. confirm the API is running in `r2-s3` mode instead of `wrangler-cli`
2. verify `R2_ACCOUNT_ID`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_BUCKET`, and `R2_PUBLIC_BASE_URL` in `infra/production/server.env`
3. verify the R2 key is bucket-scoped to `rebase-media` with `Object Read & Write`
4. restart the API after any env change with `./ops/manage.sh deploy api --no-sync`

Useful checks:

```bash
./ops/manage.sh exec api -- sh -lc 'cd /app/apps/api && node --input-type=module -e "import { getAssetUploadConfig } from \"./dist/lib/asset-storage.js\"; console.log(JSON.stringify(getAssetUploadConfig(), null, 2));"'
./ops/manage.sh logs api 200
```

Known rollout failures:

- `spawn wrangler ENOENT`: the service is in Wrangler fallback mode but the container cannot find the `wrangler` executable
- `401` from `HeadBucket` or `PutObject`: the configured R2 S3 credentials are invalid, mismatched to the account, or missing bucket write scope
- Docker build failure on `COPY geekdaily.csv`: `geekdaily.csv` is ignored by git and must not be required by the production API image build

## Database Checks

Use:
Expand Down
Loading