This repository is used to setup a local Reposilite instance to cache Maven artifacts which are downloaded during a build from public Maven repositories. A local cache for Maven artifacts can have several benefits:
- Remove intermediate dependencies from public remote repositories
- Speedup downloads for artifacts in geographics other than North America or when you have low network connectivity bandwidth
- Docker with the Docker Compose plugin
- Optional: TLS reverse proxy if is exposed to the public internet
- Data is stored as a bind mount in
./data
, change if you want a different path for persisting the data.
Step 1: Checkout the repository and switch working directory
git clone https://github.com/opennms-forge/maven-cache
cd maven-cache
Step 2: Set a secure initial admin password
cp env.sample .env
vi .env
Set a secure init admin password and save the file:
REPOSILITE_COMPOSE_OPTS=--token admin:<change-me>
Step 3: Start the service with
docker-compose up -d
cp maven-cdn.service /etc/systemd/system
systemctl daemon-reload
systemctl enable --now maven-cdn
Create a settings.xml
file for Maven with the following content:
<settings>
<mirrors>
<mirror>
<id>{My-Maven-ID}</id>
<name>{My-Name-For-This-Service}</name>
<url>{My-Maven-http(s)://my-host-or-FQDN}/upstream</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</settings>
You can use it globally for Maven if you create this file in ~/.m2/settings.xml
or specifically by using mvn --settings /path/to/my/settings.xml
.