Skip to content
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

docs: update custom remote caching documentation page #327

Merged
merged 5 commits into from
Mar 21, 2024
Merged
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
35 changes: 26 additions & 9 deletions docs/custom-remote-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,41 @@ To enable remote caching, you must configure it by hand. In fact, the `turbo log
First, you need to create the config file:

1. Create the `.turbo` folder at the root of your repository
2. Create the `config.json` file inside it, and add these two properties:
- `teamid`: it could be any string that starts with __`"team_"`__. This property will be used as a cache storage namespace for the current repository. Ex. `team_myteam`
2. Create the `config.json` file inside it, and add this property:
- `apiurl`: the address of your `turborepo-remote-cache` server.

For example:

`.turbo/config.json`
```json
{
"teamid": "team_myteam",
"apiurl": "http://localhost:3000"
"apiurl": "http://cache.ducktors.dev"
}
```
Now, you need to add the remote cache server TURBO_TOKEN to your CI pipeline or development machine. There are three ways to do it:
1. Set the `TURBO_TOKEN=yourToken` environment variable.
2. Add the token to the `turbo` global config file. You can find or create it inside the `$XDG_CONFIG_HOME/turborepo/config.json`. To know where the `XDG_CONFIG_HOME` is located on your machine, please check out the [xdg-base-directory](https://github.com/adrg/xdg#xdg-base-directory) documentation.

Now, you need to add these two environment variables TURBO_TEAM and TURBO_TOKEN to your CI pipeline or development machine. There are three ways to do it:

1. Set/export the `TURBO_TEAM=ducktors` and`TURBO_TOKEN=myGeneratedToken` as environment variable.
2. Add `teamId` and `token` to the *turbo* global config file. You can find or create it inside the `$XDG_CONFIG_HOME/turborepo/config.json`. To know where the`XDG_CONFIG_HOME` is located on your machine, please check out the [xdg-base-directory](https://github.com/adrg/xdg#xdg-base-directory) documentation. For example:

`.turbo/config.json`

```json
{
"teamid": "ducktors",
"token" : "myGeneratedToken",
"apiurl": "http://cache.ducktors.dev"
}
```

3. Modify your project `package.json` scripts by adding the `--token=yourToken` parameter. __Note: This is a less secure way to do it because the token is committed inside the repository. Prefer the other two whenever possible.__

For example:

`package.json`
```jsonc
//...
"build": "turbo run build --token=\"yourToken\"",
"build": "turbo run build --teamid=\"ducktors\" --token=\"myGeneratedToken\"",
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
Expand All @@ -63,7 +74,13 @@ ENV TURBO_TOKEN=$TURBO_TOKEN
COPY turbo.json ./
COPY .turbo/config.json ./.turbo/

RUN pnpm turbo build
RUN --mount=type=bind,source=.git,target=.git \
pnpm turbo build
```
and build your Remote Cache Server with this command:

```sh
docker buildx build --progress=plain --platform linux/amd64,linux/arm64 -f Dockerfile . --build-arg TURBO_TEAM=“ducktors” --build-arg TURBO_TOKEN=“myGeneratedToken“ --no-cache
```

## Local environment variables
Expand Down
Loading