Infrastructure-as-Code Maven Repository for Dan's Plugins Community using Docker and Docker Compose.
This repository provides a self-hosted Maven repository using Sonatype Nexus Repository Manager OSS. It's designed to be easy to deploy and manage using Docker containers.
- Docker (version 20.10 or later)
- Docker Compose (version 2.0 or later)
- At least 2GB of available RAM
- At least 10GB of available disk space
git clone https://github.com/Dans-Plugins/dpc-mvn-repo.git
cd dpc-mvn-repodocker-compose up -dThis will:
- Pull the Nexus Repository Manager OSS Docker image
- Create a persistent volume for Maven artifacts
- Start the repository on port 8081
- Web Interface: http://localhost:8081
- Default Credentials:
- Username:
admin - Password: Located in
/nexus-data/admin.passwordinside the container
- Username:
To retrieve the initial admin password:
docker exec dpc-maven-repo cat /nexus-data/admin.passwordAfter logging in and changing the default password, configure your Maven settings.xml file (usually located at ~/.m2/settings.xml):
<settings>
<servers>
<server>
<id>dpc-maven-repo</id>
<username>admin</username>
<password>your-password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>dpc-maven-repo</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</mirror>
</mirrors>
</settings>To deploy artifacts to the repository, add this to your project's pom.xml:
<distributionManagement>
<repository>
<id>dpc-maven-repo</id>
<url>http://localhost:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>dpc-maven-repo</id>
<url>http://localhost:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>Then deploy with:
mvn clean deploydocker-compose up -ddocker-compose downdocker-compose logs -fdocker-compose restartdocker-compose pull
docker-compose up -ddpc-mvn-repo/
├── docker-compose.yml # Docker Compose orchestration
├── Dockerfile # Custom Nexus image configuration
├── .gitignore # Git ignore rules
└── README.md # This file
Nexus comes with several pre-configured repositories:
- maven-central: Proxy to Maven Central
- maven-releases: Hosted repository for release artifacts
- maven-snapshots: Hosted repository for snapshot artifacts
- maven-public: Repository group combining all Maven repositories
The default configuration allocates:
- Heap Memory: 512MB
- Direct Memory: 273MB
To adjust these limits, modify the INSTALL4J_ADD_VM_PARAMS environment variable in docker-compose.yml.
By default, Nexus runs on port 8081. To change this, modify the ports mapping in docker-compose.yml:
ports:
- "9000:8081" # Change 9000 to your desired portMaven artifacts and configuration are stored in a Docker volume named nexus-data. This ensures data persists across container restarts and upgrades.
To backup the data:
docker run --rm -v dpc-mvn-repo_nexus-data:/data -v $(pwd):/backup ubuntu tar czf /backup/nexus-backup.tar.gz /dataTo restore from backup:
docker run --rm -v dpc-mvn-repo_nexus-data:/data -v $(pwd):/backup ubuntu tar xzf /backup/nexus-backup.tar.gz -C /- Change the default admin password immediately after first login
- Create separate user accounts for different teams/purposes
- Configure appropriate roles and permissions
- Enable SSL/TLS for production deployments
For production use:
- Use a reverse proxy (nginx/Apache) with SSL/TLS
- Configure firewall rules to restrict access
- Set up regular backups
- Enable authentication for all repositories
- Use strong passwords and consider token-based authentication
Check logs:
docker-compose logsCommon issues:
- Insufficient memory
- Port 8081 already in use
- Docker daemon not running
- Verify container is running:
docker-compose ps - Check if port is accessible:
curl http://localhost:8081 - Review firewall settings
Increase memory allocation in docker-compose.yml:
environment:
- INSTALL4J_ADD_VM_PARAMS=-Xms1g -Xmx1g -XX:MaxDirectMemorySize=546mFor issues and questions:
- Create an issue in this repository
- Check Nexus Repository Manager documentation
This infrastructure configuration is provided as-is for the Dan's Plugins Community.
Contributions are welcome! Please feel free to submit a Pull Request.