how to prevent gitlab ci from downloading sbt every time?

后端 未结 2 659
花落未央
花落未央 2021-02-01 08:07

We have a play2/scala application which we are building with gitlab ci.

Our .gitlab-ci.yml (at least the important part) looks as follows:

2条回答
  •  渐次进展
    2021-02-01 08:31

    There are 4 things you can do:

    1. own docker image
    2. cache
    3. artifacts
    4. use own caching solution

    The best solution will be a mix of them all.

    1. You can build your own docker image with all the dependencies you need, it's the fastest solution as it won't have to download everything but it will introduce another piece of the puzzle you need to take care of. You can use the in-built gitlab repository for storing it and have gitlab build it and then use it.
    2. You can use cache in Gitlab CI jobs so it won't have to download everything all the time. The default cache for sbt seems to be ~/.ivy2 so add
    cache:
      paths:
        - ~/.ivy2/
    

    As the first lines in your gitlab file to use the caches for each stage.

    1. Define the target directory as the artifact to pass it between builds and so you don't have to build it on each stage.
    artifacts:
      paths:
        - target/
    
    1. You can store the files you need to cache in your own s3/minio/nfs if the options supplied by gitlab are not enough. This will be a very custom solution so you will have to find your own way around it.

提交回复
热议问题