There are 4 things you can do:
- own docker image
- cache
- artifacts
- use own caching solution
The best solution will be a mix of them all.
- 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.
- 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.
- 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/
- 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.