1.0.0 • Published 4 years ago

nx-gcs-cache v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

nx-gcs-cache

A task runner for @nrwl/nx that uses a Google Cloud Storage bucket as a remote cache, so all team members and CI servers can share a single cache.

setup

npm install --save-dev nx-gcs-cache

create a Google Cloud Storage bucket. Since this is only a cache, there is no need for a dual- or multi-region bucket, so choose a single location near you.

gsutil mb -p [PROJECT_ID] -l [BUCKET_LOCATION] -b on gs://[BUCKET_NAME]/

setup a lifecycle rule for your storage bucket to automatically delete old files. If you want to use our suggested auto-delete-after-30-days rule, you can simply use the json that is included:

gsutil lifecycle set node_modules/nx-gcs-cache/lifecycle.json gs://[BUCKET_NAME]

by default all viewers, editors and owners of your Google Cloud project can read and/or write to the bucket. You could also restrict who can read and write the bucket to only allow certain users or (build server) service accounts.

finally, add tasksRunnerOptions in your nx.json file

{
    "projects": {
        ...
    },
    "tasksRunnerOptions": {
        "default": {
            "runner": "nx-gcs-cache",
            "options": {
                "bucket": "gs://NAME-OF-YOUR-STORAGE-BUCKET",
                "cacheableOperations": [
                    "build",
                    "test",
                    "lint",
                    "e2e"
                ]
            }
        }
    }
}

run a build and see if files end up in your cache storage bucket:

nx run-many --target=build --all
1.0.0

4 years ago

0.1.0

4 years ago