Skip to content

Commit

Permalink
Merge branch 'main' into all-contributors/add-adriantr
Browse files Browse the repository at this point in the history
  • Loading branch information
matteovivona authored Mar 21, 2023
2 parents 7d0848c + 254734e commit 1371e59
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ S3_ENDPOINT=
GCS_PROJECT_ID=
GCS_CLIENT_EMAIL=
GCS_PRIVATE_KEY=
# Azure Blob Storage
ABS_CONNECTION_STRING=
4 changes: 2 additions & 2 deletions .github/workflows/build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Cache
run: docker buildx build --platform linux/x86_64 --rm --push --target build --cache-from fox1t/turborepo-remote-cache:cache -t fox1t/turborepo-remote-cache:cache .
run: docker buildx build --platform linux/x86_64 --rm --push --target build --cache-from ducktors/turborepo-remote-cache:cache -t ducktors/turborepo-remote-cache:cache .

build-linux-arm64:
name: Build linux/arm64 Docker cache
Expand All @@ -40,4 +40,4 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Cache
run: docker buildx build --platform linux/arm64 --rm --push --target build --cache-from fox1t/turborepo-remote-cache:cache -t fox1t/turborepo-remote-cache:cache .
run: docker buildx build --platform linux/arm64 --rm --push --target build --cache-from ducktors/turborepo-remote-cache:cache -t ducktors/turborepo-remote-cache:cache .
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: fox1t/turborepo-remote-cache
flavor: latest=true
images: ducktors/turborepo-remote-cache
flavor: latest=false
tags: type=raw,value=${{ env.TAG }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -44,4 +44,4 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: |
fox1t/turborepo-remote-cache:cache
ducktors/turborepo-remote-cache:cache
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [1.13.2](https://github.com/ducktors/turborepo-remote-cache/compare/v1.13.1...v1.13.2) (2023-02-26)


### Bug Fixes

* **docker:** bump node from 18.14.1-alpine3.17 to 18.14.2-alpine3.17 ([c4099cc](https://github.com/ducktors/turborepo-remote-cache/commit/c4099ccc4aa97dfaf72823c0294339268778ebef))

## [1.13.1](https://github.com/ducktors/turborepo-remote-cache/compare/v1.13.0...v1.13.1) (2023-02-20)


### Bug Fixes

* **docker:** bump node from 18.14.0-alpine3.17 to 18.14.1-alpine3.17 ([872226f](https://github.com/ducktors/turborepo-remote-cache/commit/872226f62f0f29f5f046ef8787b320b56c954b3c))

# [1.13.0](https://github.com/ducktors/turborepo-remote-cache/compare/v1.12.3...v1.13.0) (2023-02-10)


Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=${TARGETPLATFORM} node:18.14.0-alpine3.17@sha256:bc329c7332cffc30c2d4801e38df03cbfa8dcbae2a7a52a449db104794f168a3 as build
FROM --platform=${TARGETPLATFORM} node:18.14.2-alpine3.17@sha256:0d2712ac2b2c1149391173de670406f6e3dbdb1b2ba44e8530647e623e0e1b17 as build

# set app basepath
ENV HOME=/home/app
Expand Down Expand Up @@ -26,7 +26,7 @@ RUN pnpm install --prod --frozen-lockfile --ignore-scripts
RUN rm -rf $PROJECT_WORKDIR/.pnpm-store

# start new image for lower size
FROM --platform=${TARGETPLATFORM} node:18.14.0-alpine3.17@sha256:bc329c7332cffc30c2d4801e38df03cbfa8dcbae2a7a52a449db104794f168a3
FROM --platform=${TARGETPLATFORM} node:18.14.2-alpine3.17@sha256:0d2712ac2b2c1149391173de670406f6e3dbdb1b2ba44e8530647e623e0e1b17

# dumb-init registers signal handlers for every signal that can be caught
RUN apk update && apk add --no-cache dumb-init
Expand Down
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,30 @@
This project is an open-source implementation of the [Turborepo custom remote cache server](https://turborepo.org/docs/features/remote-caching#custom-remote-caches). 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.

## Index
## Free Hosted Remote Cache for OSS Projects

Our vision as a collective includes helping and making the development of open-source projects as accessible as possible.

We have made available for free three remote servers (Europe, North America, and Asia) that you can use to speed up the build of your projects!

| Server | Status |
| -- | -- |
| Europe | [![Better Uptime Badge](https://betteruptime.com/status-badges/v1/monitor/mskr.svg)](https://betteruptime.com/?utm_source=status_badge)|
| North America | [![Better Uptime Badge](https://betteruptime.com/status-badges/v1/monitor/msks.svg)](https://betteruptime.com/?utm_source=status_badge)|
| Asia | [![Better Uptime Badge](https://betteruptime.com/status-badges/v1/monitor/mskt.svg)](https://betteruptime.com/?utm_source=status_badge) |

[Read more about and how to use it in the documentation.](https://ducktors.github.io/turborepo-remote-cache/free-hosted-remote-cache)

## Notable projects that use TRRC

- [GitHub Actions](https://github.com/trappar/turborepo-remote-cache-gh-action)
- [Lambda](https://github.com/cvle/turborepo-cache-lambda)

## Documentation
- [Supported Storage Providers](https://ducktors.github.io/turborepo-remote-cache/supported-storage-providers)
- [Environment variables](https://ducktors.github.io/turborepo-remote-cache/environment-variables)
- [Deployment Instructions](https://ducktors.github.io/turborepo-remote-cache/deployment-environments)
- [Enable custom remote caching in a Turborepo monorepo](https://ducktors.github.io/turborepo-remote-cache/custom-remote-caching)
## Supported Storage Providers
- [x] Local filesystem
- [x] AWS S3
- [x] Google Cloud Storage
- [x] Azure Blob Storage

[Full documentation is available here](https://ducktors.github.io/turborepo-remote-cache/supported-storage-providers)

Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: Turborepo Remote Cache
description: Open source implementation of the Turborepo custom remote cache server.
description: Open source implementation of the Turborepo Remote Cache Server.
remote_theme: just-the-docs/just-the-docs
search_enabled: true
heading_anchors: true
Expand Down
60 changes: 34 additions & 26 deletions docs/custom-remote-caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,60 @@ either add a config file by hand or set local environment variables.

You must add the config file by hand. The `turbo login` command works only with the official Vercel server.

1. create `.turbo` folder at the root of your monorepo
2. 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 running `turborepo-remote-cache` server.
1. Create the `.turbo` folder at the root of your monorepo
2. Create the `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 running `turborepo-remote-cache` server.

For example:

`.turbo/config.json`
```json
{
"teamId": "team_FcALQN9XEVbeJ1NjTQoS9Wup",
"teamId": "team_myteam",
"apiUrl": "http://localhost:3000"
}
```
3. Modify your Turborepo top-level `build` script, adding the `--token=` parameter.
__Note: The token value must be the same used for your `TURBO_TOKEN` env var. See [environment variables](https://ducktors.github.io/turborepo-remote-cache/environment-variables) section for more info.__

For example:
3. Set the `TURBO_TOKEN=yourToken` environment variable or modify your Turborepo `package.json` scripts by adding the `--token=yourToken` parameter.

`package.json`
```jsonc
//...
"build": "turbo run build --token=\"yourToken\"",
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
//...
```
For example:

### Enable remote caching in Docker
For some reason, the `.turbo/config.json` is not working in Docker containers. In order to enable remote caching in Docker, you need to pass the configuration via CLI arguments.

`package.json`
```json
"build": "turbo run build --team=\"team_awesome\" --token=\"turbotoken\" --api=\"https://your-caching.server.dev\"",
//...
"build": "turbo run build --token=\"yourToken\"",
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
//...
```
__Note: The token value must be the same used for your server's `TURBO_TOKEN` env var. See the [environment variables](https://ducktors.github.io/turborepo-remote-cache/environment-variables) section for more info.__

## Enable remote caching in Docker
To enable remote caching in Docker, you must pass TURBO_TOKEN inside Dockerfile and temporarily add the `.git` folder to enable the turbo caching. After the build, you should remove the `.git` folder.
For example:

```
ENV TURBO_TOKEN=
COPY turbo.json ./
COPY .turbo/config.json ./.turbo/
COPY .git/ ./.git/
RUN pnpm turbo build
RUN rm -rf .git
```

## Local environment variables

You can also configure your developer environment by setting the following
environment variables:
You can also configure your development machine by setting the following environment variables, instead of using the config file:

| Variable | Type | Description |
| ------------- | ------ | ----------- |
| `TURBO_API` | string | The address of a running `turborepo-remote-cache` server |
| `TURBO_TEAM` | string | The team id (see *Config file* above)|
| `TURBO_TOKEN` | string | Your secret key. This must be the same as the `TURBO_TOKEN` variable set on your turborepo-remote-cache server |
| `TURBO_TEAM` | string | The teamId (see *Config file* above)|
| `TURBO_TOKEN` | string | Your secret key. This must be the same as the `TURBO_TOKEN` variable set on your turborepo-remote-cache server instance |

**Note, these environment variables are used by the Turborepo CLI, so should not
be confused with the environment variables used to configure your server!**
**Note: these environment variables are used by the Turborepo CLI** on the development machine or CI pipelines. They are not used by the `turborepo-remote-cache` server.
41 changes: 41 additions & 0 deletions docs/free-hosted-remote-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
layout: default
title: Free Hosted Remote Cache
parent: Deployment Environments
nav_order: 1
---

# Disclaimer
The maintainers and contributors of the GitHub Ducktors organization assumes no responsibility for errors or omissions in the artifacts/cache of Turborepo Remote Cache Free Servers.

In no event shall the maintainers and contributors of the GitHub Ducktors organization be liable for any special, direct, indirect, consequential, or incidental damages or any damages whatsoever, whether in an action of contract, negligence or other tort, arising out of or in connection with the use of the Turborepo Remote Cache Free Servers.

The maintainers and contributors of the GitHub Ducktors organization does not warrant that the Turborepo Remote Cache Free Servers is free other harmful components.

**No Responsibility Disclaimer**

The artifacts/cache given by Turborepo Remote Cache Free Servers is for general guidance on matters of interest only. Even if maintainers and contributors of the GitHub Ducktors organization takes every precaution to insure that the artifacts/cache of Turborepo Remote Cache Free Servers is both current and accurate, errors can occur. Plus, given the changing nature of laws, rules and regulations, there may be delays, omissions or inaccuracies in the information contained on Turborepo Remote Cache Free Servers.

**Errors and Omissions Disclaimer**

Maintainers and contributors of the GitHub Ducktors organization is not responsible for any errors or omissions, or for the results obtained from the use of this information.

**"Use at Your Own Risk" Disclaimer**

All information in Turborepo Remote Cache Free Servers is provided "as is", with no guarantee of completeness, accuracy, timeliness or of the results obtained from the use of this information, and without warranty of any kind, express or implied, including, but not limited to warranties of performance, merchantability and fitness for a particular purpose.

Maintainers and contributors of the GitHub Ducktors organization will not be liable to You or anyone else for any decision made or action taken in reliance on the information given by Turborepo Remote Cache Free Servers or for any consequential, special or similar damages, even if advised of the possibility of such damages.

# Configure your projecy

You can configure your project by following [this guide](https://ducktors.github.io/turborepo-remote-cache/custom-remote-caching.html).

Variables can be set according to the following parameters of each server. It is up to you to choose which server is closest to your current location.

| Server | Status | TURBO_API | TURBO_TOKEN |
| -- | -- | -- | -- |
| Europe | [![Better Uptime Badge](https://betteruptime.com/status-badges/v1/monitor/mskr.svg)](https://betteruptime.com/?utm_source=status_badge)| `https://eu.trrc.ducktors.dev` |`turbotoken-oss-europe1` |
| North America | [![Better Uptime Badge](https://betteruptime.com/status-badges/v1/monitor/msks.svg)](https://betteruptime.com/?utm_source=status_badge)| `https://us.trrc.ducktors.dev` |`turbotoken-oss-usa1` |
| Asia | [![Better Uptime Badge](https://betteruptime.com/status-badges/v1/monitor/mskt.svg)](https://betteruptime.com/?utm_source=status_badge) |`https://as.trrc.ducktors.dev`|`turbotoken-oss-asia1` |


1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ It supports several storage providers and deploys environments. Moreover, the pr
- [Environment variables](https://ducktors.github.io/turborepo-remote-cache/environment-variables)
- [Deployment Instructions](https://ducktors.github.io/turborepo-remote-cache/deployment-environments)
- [Enable custom remote caching in a Turborepo monorepo](https://ducktors.github.io/turborepo-remote-cache/custom-remote-caching)
- [Free Hosted Remote Cache](https://ducktors.github.io/turborepo-remote-cache/free-hosted-remote-cache)
21 changes: 19 additions & 2 deletions docs/supported-storage-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ nav_order: 3

# Supported Storage Providers

## AWS Credentials and Region
- [x] Local filesystem
- [x] AWS S3
- [x] Google Cloud Storage
- [x] Azure Blob Storage

## AWS S3

### Credentials and Region

AWS credentials and configuration are loaded as described in the AWS SDK documentation:

Expand All @@ -22,7 +29,9 @@ configure these.

Specify the region using the `AWS_REGION` environment variable, or in `~/.aws/config`.

## Configure Google Cloud Storage

## Google Cloud Storage

1. Create a [bucket](https://console.cloud.google.com/storage/browser) (or use an existing one)
2. Create a new [service account](https://console.cloud.google.com/iam-admin/serviceaccounts).
3. Grant the role `Storage Object Admin` to the service account on the bucket.
Expand All @@ -32,6 +41,7 @@ Specify the region using the `AWS_REGION` environment variable, or in `~/.aws/co
STORAGE_PATH=<name-of-the-bucket>
```
### Using static Service Account credentials

1. Click "Create Key" and save the JSON file.
1. Add the `project_id` , `client_email`, and `private_key` from saved JSON file to `.env` (or wherever you manage your environment variables):
```sh
Expand All @@ -41,10 +51,17 @@ Specify the region using the `AWS_REGION` environment variable, or in `~/.aws/co
GCS_PRIVATE_KEY=<private_key>
```
### Using Application Default Credentials (ADC)

1. Do not set `GCS_*` environment variables
```sh
# .env
GCS_PROJECT_ID=
GCS_CLIENT_EMAIL=
GCS_PRIVATE_KEY=
```

## Azure Blob Storage

1. Create a new Blob Storage
2. On "Security + networking" tab, copy one of `Connection string` on "Access keys" blade
3. Set `ABS_CONNECTION_STRING` with Connection string value
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turborepo-remote-cache",
"version": "1.13.0",
"version": "1.13.2",
"description": "Turborepo remote cache server",
"main": "build",
"author": "Maksim Sinik <[email protected]>",
Expand Down

0 comments on commit 1371e59

Please sign in to comment.