Turborepo-compatible Remote Cache built on the Supercloud
A Cloudflare Community Project
NOTE: We are currently in the process of moving to a monorepo structure for this project, to allow for the Simple and the SaaS Architecture to be developed in parallel. The structure of the repository may change in the near future.
LEGAL: This Github Repository, and the Organization it belongs to, is not managed or maintained by Cloudflare, or its employees. This project and/or this Organization are not condoned/recommended by Cloudflare. Views expressed here do not represent the views of Cloudflare or its employees. All rights to the Cloudflare Logo and other assets belong to Cloudflare Inc.
Corsica is a remote cache for Turborepo that uses Cloudflare Workers and R2 to store build artifacts. It automatically caches, and subsequently invalidates, build artifacts for your Turborepo projects. It also collects analytics on the build artifacts that are cached, using Analytics Engine.
- Corsica doesn't currently handle Vercel Analytics events. Is this worth pursuing?
- Clone the repo, and install dependencies with
pnpm
(now required for Workspaces support). - Generate your API tokens and usernames. They should be in the following format:
{
"<key>": "<username>",
"1Il6JKzywIzeDkiJVnh56": "alastair"
// ...
}
- Move to
apps/simple
- Replace the
account_id
androute
fields in yourwrangler.json
file with your Cloudflare account ID and the route you want to use for your cache. - Deploy the API token json as an environment variable called
API_TOKENS
in your Cloudflare Worker.
$ wrangler secret put -j AUTH_TOKENS
⛅️ wrangler 3.4.0
------------------
✔ Enter a secret value: …
🌀 Creating the secret for the Worker "turbo"
✨ Success! Uploaded secret AUTH_TOKENS
- Deploy the Worker
$ wrangler deploy -j
⛅️ wrangler 3.4.0
------------------
Your worker has access to the following bindings:
- Durable Objects:
- EXPIRE: Expire
- R2 Buckets:
- R2: turbo
- Analytics Engine Datasets:
- AE: TurborepoAnalytics
Total Upload: 23.55 KiB / gzip: 8.48 KiB
Uploaded turbo (3.89 sec)
Published turbo (8.33 sec)
turbo.goalastair.com (custom domain)
Current Deployment ID: f6bfbc67-3ba0-4c6d-ac53-835b6a6af8ad
- Create a
.turbo/config.json
file in the root of your repository. At the moment, it appears thatturbo
requires ateamid
to be defined for it to enable remote caching. Whilecorsica
doesn't currently silo caches by team, you'll need to define ateamid
in your config file. It can be anything you want, as long as it's a string.
{
"apiurl": "<Your Worker Domain>",
"teamid": "<Your Team ID>
}
- Add an environment variable to your shell called
TURBO_TOKEN
, with the value of your API token. - >>> FULL TURBO