Skip to content

gpdenny/turborepo-s3-cache

Repository files navigation

Turborepo S3 Cache

serverless-badge node-badge ci-badge stars-badge license-badge

Serverless Turborepo remote caching using API Gateway and S3.

Description

This project is a serverless implementation of the Turborepo custom remote cache server.

It makes use of the preflight Turborepo feature to return signed S3 URLs to the client to upload/download artifacts directly from S3.

Build and Deployment is managed by the Serverless Framework.

diagram

Getting Started

  1. Clone this repo

    git clone git@github.com:gpdenny/turborepo-s3-cache.git
  2. Install dependencies

    yarn install
  3. Copy example environment variables

    You can do this for each environment you might wish to deploy to, for example, dev.

    cp .env.example .env.dev
  4. Modify environment variables to your requirements

  • SERVICE_NAME - Serverless service name, used to prefix all AWS resources
  • REGION - The AWS Region to deploy the service to
  • TEAMS_TABLE_NAME - Name for the DynamoDB teams table see below
  • CACHE_BUCKET_NAME - Name for the artifacts S3 bucket
  • CACHE_EXPIRATION_DAYS - Number of days cache artifacts are kept in S3 before being deleted
  1. Run Serverless deploy

    Include the stage flag, with the environment you wish to deploy.

    yarn serverless deploy --stage dev
  2. Populate the Teams DynamoDB table

    aws dynamodb put-item \
        --table-name `TEAMS_TABLE_NAME`  \
        --item \
            '{"name": {"S": "myteam"}, "tokens": {"L": [{"S": "token_1"}, {"S": "token_2"}]}}'
  3. Add remote cache to your Turborepo config

    .turbo/config.json

    {
        "teamId": "team_myteam",
        "apiUrl": "https://fxbu8kd8i.execute-api.eu-central-1.amazonaws.com/dev/"
    }

    package.json

    [...]
    "lint": "turn run lint --token'\"token1\""
    [...]

    Read More

Authors

Gareth Denny

Acknowledgments

Inspiration, code snippets, etc.

About

Serverless Turborepo remote cache

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published