This image provides a very simple repository proxy for Maven routing incoming requests to the correct remote repository based on groupId prefix.
The proxy is intended to be run close to the build environment typically as part of the build process on the CI server. It aims to improve build performance and security by avoiding obsolete network requests for artifacts known to be located on a specific repository. It's a pity that Maven does not support this out of the box.
Run the proxy with Docker:
$ docker run -it -p 8181:8181 \ -e REPO1_URL=https://repo1 \ -e REPO1_USERNAME=username \ -e REPO1_PASSWORD=password \ -e REPO1_INCLUDES=com.example,org.example \ raehalme/maven-routing-proxy
You may specify up to 10 repositories with environment variables. The default repository is Maven Central and can be overridden with environment variable
Next, you'll need to configure your Maven to use the proxy as a mirror for all repositories. This is done with the help of the Maven settings file which should be located at
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <mirror> <url>http://localhost:8181</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors> </settings>
Now you have configured your Maven setup to download all dependencies through your routing proxy. You'll probably want to use this with your CI server running in the cloud, eg. Bitbucket Pipelines.