Gitlab -ci :前后端项目加载缓存,减少构建时间
我们使用cache关键字,定义缓存路径 ,在build的时候加载缓存后端项目java先看效果,加载缓存之前要3分钟多加载之后,27s多,效果非常明显配置也比较简单,我们只需要在gitlab-ci.yaml里面增加以下配置就好variables:MAVEN_OPTS: -Dmaven.repo.local=/cache/maven.repositorycache:k...
文章共635字 · 阅读需要大约3分钟
一键AI生成摘要,助你高效阅读
问答
·
我们使用cache关键字,定义缓存路径 ,在build的时候加载缓存
后端项目java
先看效果,加载缓存之前要3分钟多
加载之后,27s多,效果非常明显
配置也比较简单,我们只需要在gitlab-ci.yaml里面增加以下配置就好
variables:
MAVEN_OPTS: -Dmaven.repo.local=/cache/maven.repository
cache:
key: PortalReportBackend
paths:
- /root/.m2/repository
前端项目vue
我们前端项目是vue项目,使用yarn编译 ,之前每次yarn install / yarn run build 需要20min左右
使用缓存配置之后 ,时间节省了1500多秒,效果显著
配置如下:
另外在install stage里面增加如下:
cache:
key: 项目名
paths:
- $(pwd)/.yarn-cache
- node_modules/
install:
image: node:latest
stage: Install
script:
- echo 'nameserver 223.5.5.5'>>/etc/resolv.conf
- yarn config set registry 'https://registry.npm.taobao.org'
- yarn config set sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
- yarn config set phantomjs_cdnurl "http://cnpmjs.org/downloads"
- yarn config set electron_mirror "https://npm.taobao.org/mirrors/electron/"
- yarn config set sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
- yarn config set profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
- yarn config set chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
- yarn config set cache-folder $(pwd)/.yarn-cache
更多推荐
已为社区贡献5条内容
所有评论(0)