This project is an open-source implementation of the Turborepo custom remote cache server. If Vercel's official cache server isn't a viable option, this server is an alternative for self-hosted deployments. It supports several storage providers and deploys environments. Moreover, the project provides "deploy to " buttons for one-click deployments whenever possible.
- Supported Storage Providers
- ENV VARS
- Deployment Instructions
- Enable custom remote caching in a Turborepo monorepo
- Local filesystem
- AWS S3
- Azure Blob Storage (WIP)
- Google Cloud Storage (WIP)
- Google Drive Blobs (WIP)
NODE_ENV
: String. Optional. Possible values:development | production
. Default value:production
.PORT
: Number. Optional. Default value:3000
.TURBO_TOKEN
: String. Secret token used for the authentication. The value must be the same one provided for thetoken
parameter of thebuild
script. See Enable custom remote caching in a Turborepo monorepo for more info. This value should be private.LOG_LEVEL
: String. Optional. Default value:'info'
STORAGE_PROVIDER
: Optional. Possible values:local | s3
. Default value: "local". Use this var to choose the storage provider.STORAGE_PATH
: String. Caching folder. IfSTORAGE_PROVIDER
is set tos3
, this will be the name of the bucket.S3_ACCESS_KEY
: String. Used only ifSTORAGE_PROVIDER=s3
S3_SECRET_KEY
: String. Used only ifSTORAGE_PROVIDER=s3
S3_REGION
: String. Used only ifSTORAGE_PROVIDER=s3
S3_ENDPOINT
: String. Optional. Used only ifSTORAGE_PROVIDER=s3
. NOTE: This var can be omitted if the other s3 vars are provided.
To enable a custom remote caching server in your Turborepo monorepo, you must add a config file by hand. The turbo login
command works only with the official Vercel server.
- create
.turbo
folder at the root of your monorepo - create
config.json
file inside it, and add these properties:teamId
: it could be any string that starts with"team_"
. This property will be used as a cache storage folder for the current repository. Ex.team_myteam
apiUrl
: address of a runningturborepo-remote-cache
server.
For example:
.turbo/config.json
{
"teamId": "team_FcALQN9XEVbeJ1NjTQoS9Wup",
"apiUrl": "http://localhost:3000"
}
- Modify your Turborepo top-level
build
script, adding the--token=
parameter. Note: The token value must be the same used for yourTURBO_TOKEN
env var. See ENV_VARS section for more info.
For example:
package.json
//...
"build": "turbo run build --token=\"yourToken\"",
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
//...
The server can be easily deployed as Vercel Function using the deploy button.
Note: Local storage isn't supported for this deployment method.
You can find the image on the dockerhub.
- create an
.env
file, containing all of the env vars you need. Check ENV_VARS for more info.
NODE_ENV=
PORT=
TURBO_TOKEN=
LOG_LEVEL=
STORAGE_PROVIDER=
STORAGE_PATH=
S3_ACCESS_KEY=
S3_SECRET_KEY=
S3_REGION=
S3_ENDPOINT=
- run the image using the
.env
file created on the step one.
docker run --env-file=.env -p 3000:3000 fox1t/turborepo-remote-cache
-
clone this repository
git clone [email protected]:fox1t/turborepo-remote-cache.git
-
cd turborepo-remote-cache
-
npm i
-
cp env.example env
-
put your env vars to the
env
file. See ENV_VARS section for more details. -
npm run dev