Skip to content

Dans-Plugins/dpc-mvn-repo

Repository files navigation

DPC Maven Repository

Infrastructure-as-Code Maven Repository for Dan's Plugins Community using Docker and Docker Compose.

Overview

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.

Prerequisites

  • 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

Quick Start

1. Clone the Repository

git clone https://github.com/Dans-Plugins/dpc-mvn-repo.git
cd dpc-mvn-repo

2. Start the Maven Repository

docker-compose up -d

This will:

  • Pull the Nexus Repository Manager OSS Docker image
  • Create a persistent volume for Maven artifacts
  • Start the repository on port 8081

3. Access the Repository

  • Web Interface: http://localhost:8081
  • Default Credentials:
    • Username: admin
    • Password: Located in /nexus-data/admin.password inside the container

To retrieve the initial admin password:

docker exec dpc-maven-repo cat /nexus-data/admin.password

4. Configure Maven Settings

After 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>

5. Deploy Artifacts

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 deploy

Management Commands

Start the Repository

docker-compose up -d

Stop the Repository

docker-compose down

View Logs

docker-compose logs -f

Restart the Repository

docker-compose restart

Update to Latest Version

docker-compose pull
docker-compose up -d

Repository Structure

dpc-mvn-repo/
├── docker-compose.yml    # Docker Compose orchestration
├── Dockerfile            # Custom Nexus image configuration
├── .gitignore           # Git ignore rules
└── README.md            # This file

Default Repositories

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

Configuration

Resource Limits

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.

Port Configuration

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 port

Data Persistence

Maven 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 /data

To 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 /

Security

Initial Setup

  1. Change the default admin password immediately after first login
  2. Create separate user accounts for different teams/purposes
  3. Configure appropriate roles and permissions
  4. Enable SSL/TLS for production deployments

Production Deployment

For production use:

  1. Use a reverse proxy (nginx/Apache) with SSL/TLS
  2. Configure firewall rules to restrict access
  3. Set up regular backups
  4. Enable authentication for all repositories
  5. Use strong passwords and consider token-based authentication

Troubleshooting

Container Won't Start

Check logs:

docker-compose logs

Common issues:

  • Insufficient memory
  • Port 8081 already in use
  • Docker daemon not running

Can't Access Web Interface

  1. Verify container is running: docker-compose ps
  2. Check if port is accessible: curl http://localhost:8081
  3. Review firewall settings

Slow Performance

Increase memory allocation in docker-compose.yml:

environment:
  - INSTALL4J_ADD_VM_PARAMS=-Xms1g -Xmx1g -XX:MaxDirectMemorySize=546m

Support

For issues and questions:

License

This infrastructure configuration is provided as-is for the Dan's Plugins Community.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •