When building frontend projects with npm, it’s common for dependency downloads to take a long time, and reusing artifacts or caches across different jobs is also challenging. Whether using artifacts or cache, we ultimately need persistent reuse of files. Here, we’ll use cache as an example.
Note: The GitLab Runner is deployed to the Kubernetes cluster via Helm chart (deployment details are omitted). You must prepare a Ceph S3 key pair in advance for configuring accesskey and secretkey.
cache:## General settingscacheType:s3cachePath:"devops"# Specify the Ceph S3 cache path; here we use department names for separationcacheShared:true## S3 settingss3ServerAddress:"ops-rgw.test.cn"s3BucketName:"runners-cache"s3BucketLocation:s3CacheInsecure:truesecretName:"gitlab-runner-s3"
After triggering the GitLab CI job, observe the real-time job execution. At this point, cache files have been uploaded to Ceph S3. Subsequent builds will be significantly faster!
64Creating cache devops-vue-4...65 node_modules/:found 30710 matching files and directories66 .yarn:found 34390 matching files and directories 67Uploading cache.zip to https://ops-rgw.test.cn/runners-cache/devops/project/4187/devops-vue-js-starter-468Created cache70Cleaning up file based variables00:0072Job succeeded