Skip to content

visbot/turbofan-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turbofan

Self-hosted remote cache for Turborepo

We're all fans of Turborepo, but for the speediest Full Turbo builds you need a remote cache. Turbofan lets you deploy your own, self-hosted remote cache in just a few clicks.

Usage

You have two options for deploying Turbofan:

Shared instance

Deploy a standalone instance of Turbofan that can be used by multiple Turborepo projects

Clone this repo or click the button below to deploy Turbofan to Netlify:

Deploy to Netlify

You'll need to enter a shared secret that will be used to authenticate with Turbofan and then provide this secret to all of your Turborepo projects. A quick way to generate a token on Mac OS or Linux is to run uuidgen in your terminal.

Per-project instance

You can add a Turbofan instance to your Turborepo project by adding a Netlify Edge Function to your project. There is no need to install anything as it can be imported directly from deno.land.

// netlify/edge-functions/turbofan.ts

export { handleRequest as default } from "https://deno.land/x/turbofan/mod.ts";

export const config = {
	method: ["GET", "PUT"],
	path: "/v8/artifacts/:hash",
	cache: "manual",
};

Setting up your Turborepo project

Once you have deployed Turbofan, you will need to configure your Turborepo project to use it. You can do this by creating the following file in your project and committing it to your repository:

.turbo/config.json

{
	"teamid": "team_anythingyouwant",
	"apiurl": "https://<your cache url goes here>.netlify.app"
}

The teamid can be anything you want, as long as it starts with team_. This will segment your project in the cache.

The API url should be the URL of your Turbofan instance. This will either be the URL of the standalone cache, or the URL of your Netlify site if you are using a per-project instance.

You then need to provide the shared secret as an env var to the builds:

TURBO_TOKEN=your-secret-here

You can set this in the Netlify UI, or in the CLI by running netlify env:set.

Troublehooting

You can check that it is working by looking for "Remote caching enabled" in the logs. Be aware that the first build for a per-site instance will not use the cache, as the Edge Function needs to be deployed before it can be used.

You can check the logs for the Edge Function to see if the artifacts are being cached and returned correctly.

If you don't see "Remote caching enabled", check that you have set the TURBO_TOKEN env var correctly and have created the .turbo/config.json file.

License

Copyright 2023 Matt Kane. Available under the terms of the MIT license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published