This repository provides a streamlined process for setting up and managing a self-hosted Turborepo remote cache on Google Cloud, utilizing the ducktors/turborepo-remote-cache project.
![architecture](https://private-user-images.githubusercontent.com/38521709/246704775-4c256d26-c8ba-46e9-87bd-7f4fe41e652c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNzg3MjgsIm5iZiI6MTczOTM3ODQyOCwicGF0aCI6Ii8zODUyMTcwOS8yNDY3MDQ3NzUtNGMyNTZkMjYtYzhiYS00NmU5LTg3YmQtN2Y0ZmU0MWU2NTJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDE2NDAyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjNDliNGU2Mjk5ZDY0ZjIzN2E2Y2RiYzcyYmZkYzBjYzQ2OThiZWUwM2NjMDVjMzk5MTk3MWM1YzcxMzVlNTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.rflsAugk0I4VNmxyxSfDOPEn5gNc7R1BkRhb1Tm1_Nk)
- Clone this repository
- Ensure Terraform is set up and the "Resource Manager API" is enabled on Google Cloud
- Create service accounts with the following roles:
- Editor (or roles with sufficient permissions to create necessary resources)
- Secret Manager Admin
- Security Admin
- Download the private key (in JSON format) of the service account and place it in the root of this repository as "credentials.json"
-
Authenticate the gcloud CLI:
gcloud auth login --cred-file=./credentials.json
-
Prepare your Terraform variables:
cp terraform.tfvars.example terraform.tfvars # Edit the copied file (terraform.tfvars) with your details
-
Initialize and apply your Terraform configuration:
cd terraform terraform init terraform plan terraform apply
-
Pull the fox1t/turborepo-remote-cache image from Docker Hub and push it to your Artifact Registry:
Click here for detailed instructions
# only amd64 image works docker pull fox1t/turborepo-remote-cache:(tag)@(digest-of-amd64-image) docker tag fox1t/turborepo-remote-cache:(tag)@(digest-of-amd64-image) (artifact-registry-repository-location)/turborepo-remote-cache:(tag) docker push (artifact-registry-repository-location)/turborepo-remote-cache:(tag)
-
Now your remote cache server is set up and ready to use! 🚀
turbo run ${command} \ --api=${cloud run url} \ --team=${your team name} \ --token=${turbo_token in terraform.tfvars}
Note: If you push another image into the Artifact Registry, a new revision will be created automatically.
Enjoy your self-hosted Turborepo remote cache!
Any feature requests or pull requests are welcome!