> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sonatype Nexus Repository

> Ready-to-run Nexus Repository Manager container template for artifact management and private registry.

## Overview

This template provides a production‑ready Nexus Repository Manager instance as a Monk runnable. You can:

* Run it directly to get a managed artifact repository and package manager
* Inherit it in your own CI/CD infrastructure to host private packages and cache public repositories

Nexus Repository is a universal artifact repository manager supporting all major formats: Maven, npm, Docker, PyPI, RubyGems, NuGet, and more. It proxies remote repositories and hosts your private artifacts.

## What this template manages

* Nexus Repository Manager OSS or Pro
* Web UI and API
* Repository management
* Docker registry capabilities
* Blob storage for artifacts
* Web UI on port 8081

## Quick start (run directly)

1. Load templates

```bash theme={null}
monk load MANIFEST
```

2. Run Nexus with defaults

```bash theme={null}
monk run nexus/nexus
```

3. Customize configuration (recommended via inheritance)

Running directly uses the defaults defined in this template's `variables`. Secrets added with `monk secrets add` will not affect this runnable unless you inherit it and reference those secrets.

* Preferred: inherit and replace variables with `secret("...")` as shown below.
* Alternative: fork/clone and edit the `variables` in `nexus/nexus.yaml`, then `monk load MANIFEST` and run.

Once started, access Nexus at `http://localhost:8081`.

Default credentials: `admin` / `admin123` (change immediately!)

## Configuration

Key variables you can customize in this template:

```yaml theme={null}
variables:
  nexus-image-tag: "latest"             # container image tag
  nexus-port: "8081"                    # web UI and API port
  docker-port: "8082"                   # Docker registry port (hosted)
  docker-group-port: "8083"             # Docker group port
  java-opts: "-Xms2703m -Xmx2703m"     # JVM heap options
  max-direct-memory: "2703m"            # JVM direct memory
```

Data is persisted under `${monk-volume-path}/nexus` on the host. Nexus data directory is mounted at `/nexus-data` in the container.

## Use by inheritance (recommended for CI/CD)

Inherit the Nexus runnable in your CI/CD pipeline and declare a connection. Example:

```yaml theme={null}
namespace: myorg
artifacts:
  defines: runnable
  inherits: nexus/nexus
ci:
  defines: runnable
  containers:
    ci:
      image: myorg/ci-runner
      environment:
        - NEXUS_URL=http://artifacts:8081
        - NEXUS_USER=<- secret("nexus-user")
        - NEXUS_PASSWORD=<- secret("nexus-password")
  connections:
    repo:
      runnable: artifacts
      service: nexus
```

Then set the secrets once and run your CI/CD stack:

```bash theme={null}
monk secrets add -g nexus-user="ci-user"
monk secrets add -g nexus-password="STRONG_PASSWORD"
monk run myorg/ci
```

## Ports and connectivity

* Service: `nexus` on TCP port `8081` (Web UI and API)
* Docker Registry (hosted): TCP port `8082`
* Docker Registry (group): TCP port `8083`
* From other runnables in the same process group, use `connection-hostname("\<connection-name>")` to resolve the Nexus host.

## Persistence and configuration

* Data path: `${monk-volume-path}/nexus/nexus-data:/nexus-data`
* Blob stores: `${monk-volume-path}/nexus/blobs`
* You can configure additional blob stores and repositories through the Nexus web UI at `http://localhost:8081`.

## Features

* **Universal Repository**: Support for 25+ package formats
* **Proxy Repositories**: Cache remote repositories (Maven Central, npm, PyPI)
* **Hosted Repositories**: Host your private artifacts
* **Group Repositories**: Combine multiple repos into one URL
* **Docker Registry**: Private Docker image registry
* **Security**: Fine-grained access control, LDAP/AD integration
* **High Availability**: Clustering and replication (Pro)
* **Storage**: Efficient blob storage with deduplication

## Supported Formats

* **Build Tools**: Maven, Gradle, Ivy
* **Package Managers**: npm, PyPI, RubyGems, NuGet, Composer
* **Containers**: Docker, Helm
* **OS Packages**: APT, Yum, Conan
* **Raw**: Generic files, site repositories
* **And many more...**

## Maven Configuration

Configure Maven to use Nexus in `~/.m2/settings.xml`:

```xml theme={null}
<settings>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>
  <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
</settings>
```

## npm Configuration

Configure npm to use Nexus:

```bash theme={null}
npm config set registry http://localhost:8081/repository/npm-group/
npm login --registry=http://localhost:8081/repository/npm-hosted/
```

## Docker Registry

Configure Docker to use Nexus:

```bash theme={null}
# Login to Nexus Docker registry
docker login localhost:8082

# Tag and push image
docker tag myimage:latest localhost:8082/myimage:latest
docker push localhost:8082/myimage:latest

# Pull image
docker pull localhost:8082/myimage:latest
```

## Use cases

Nexus excels at:

* Private artifact repository
* Proxy for public repositories (faster builds, offline capability)
* Docker registry for private images
* Package management for polyglot teams
* License compliance and security scanning
* Dependency management

## Related templates

* Integrate with source control (GitLab, GitHub)
* Use with artifact repositories (`nexus/`, `artifactory/`)
* Combine with container registries for Docker image management

## Troubleshooting

* If you changed credentials or configuration but the container has existing data, you may need to update settings through the Nexus web UI.
* Nexus requires 2-3 minutes on first launch to initialize.
* For memory issues, increase `java-opts` heap size in the template variables.
* Get initial admin password:

```bash theme={null}
cat ${monk-volume-path}/nexus/nexus-data/admin.password
```

* Check logs:

```bash theme={null}
monk logs -l 500 -f nexus/nexus
```
