diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-11 06:16:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-11 06:16:07 +0300 |
commit | f60515eae2fc00c56742462826ae00826eb8826e (patch) | |
tree | d8d3cc877f7f9d9c20d27dd95eb145918d2d77bb /doc/ci/caching/index.md | |
parent | d9c0b200e192c340f50fa165a66e4b6ff805f9fc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/ci/caching/index.md')
-rw-r--r-- | doc/ci/caching/index.md | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/doc/ci/caching/index.md b/doc/ci/caching/index.md index 491454aed28..c634491662d 100644 --- a/doc/ci/caching/index.md +++ b/doc/ci/caching/index.md @@ -235,6 +235,39 @@ test_async: - node ./specs/start.js ./specs/async.spec.js ``` +#### Compute the cache key from the lock file + +You can use [`cache:key:files`](../yaml/index.md#cachekeyfiles) to compute the cache +key from a lock file like `package-lock.json` or `yarn.lock`, and reuse it in many jobs. + +```yaml +# Cache modules using lock file +cache: + key: + files: + - package-lock.json + paths: + - .npm/ +``` + +If you're using [Yarn](https://yarnpkg.com/), you can use [`yarn-offline-mirror`](https://classic.yarnpkg.com/blog/2016/11/24/offline-mirror/) +to cache the zipped `node_modules` tarballs. The cache generates more quickly, because +fewer files have to be compressed: + +```yaml +job: + script: + - echo 'yarn-offline-mirror ".yarn-cache/"' >> .yarnrc + - echo 'yarn-offline-mirror-pruning true' >> .yarnrc + - yarn install --frozen-lockfile --no-progress + cache: + key: + files: + - yarn.lock + paths: + - .yarn-cache/ +``` + ### Cache PHP dependencies If your project uses [Composer](https://getcomposer.org/) to install |