Docker caching of .m2 doesn't work locally

只谈情不闲聊 提交于 2019-12-04 17:01:37

As in this issue, you need to put your m2 cache folder into a volume, or the container would start from scratch (empty cache) every time, promting maven to download everything all over again.

That issue also reports, instead of using volumes:

The cache.paths value doesn't need to be specified if you point the repo to something in /cache; the version I'm actually using currently is below, and I don't see the 'Removing..' line for .m2:

image:
  maven:3.3.9-jdk-8

variables:
  MAVEN_OPTS: -Dmaven.repo.local=/cache/maven.repository

test:
  script: "mvn test" 

But using a volume remains the most portable solution:

We edit our config to include a local docker host volume named host-cache, and we just replace /cache references above with /host-cache which doesn't depend on any undocumented runner defaults.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!