Setting the cache at the project level

You can set which path is to be cached in the .gitlab-ci.yml file for the project itself:

 cache:
paths:
- node_modules/

The preceding settings apply to the context of just a single Runner host. If we use autoscaling, we need a way to have this cache shared by all of the runners to help gain speed. We can use external storage such as an S3 bucket to act as a cache. We just have to add the [runners.cache.s3] part to the config.toml file of the runners:

     [runners.cache.s3]
ServerAddress = "s3-website-us-east-1.amazonaws.com"
BucketName = "joustie-gitlab-runner-cache"
AccessKey = "xxx"
SecretKey= "xxxx"
Insecure = false

If this is your first time doing this, it will try to get the cache.zip file from the S3 storage bucket. However, if there is no file, it will complain and continue:

Checking cache for default...
FATAL: file does not exist

After the build, which populates the node_modules directory with dependencies, the contents of that directory is zipped and sent to the S3 storage bucket:

Creating cache default...
node_modules/: found 5728 matching files
Uploading cache.zip to https://joustie-gitlab-runner-cache.s3.amazonaws.com/project/14/default
Created cache
Job succeeded

If we retry the job, we will find that there's now a cache.zip file in S3, and it will be used instead of downloading all of those node dependencies again:

Checking cache for default...
Downloading cache.zip from https://joustie-gitlab-runner-cache.s3.amazonaws.com/project/14/default
Successfully extracted cache
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.1.136