Local maven cache setup
This approach is 3-4 times faster then anything i've tried e.g RUN mvn dependency:go-offline
The most portable solution till now seems to be a local nexus image running locally proxying the dependency downloads.
The problem with a prepackaged image that already has the dependencies is that you will have to first rebuild the image builder before you run your multistage maven build for the project.
Pull the image
$ docker pull sonatype/nexus3
Create a persistent volume:
$ docker volume create --name nexus-data
Run the image
$ docker run -d -p 8081:8081 --name nexus -v nexus-data:/nexus-data sonatype/nexus3
Get in the container console:
docker exec -it <container-id> bash
cat /nexus-data/admin.password
Create a Repository Group
add a settings file that mirrors all repos and points them to the Repository Group
in your Dockerfile copy the settings file
COPY settings.xml "/root/.m2/settings.xml"
...
here you can finde an example for a springboot application that uses a skaffold build for the local Kubernetes Cluster. github project