Appendix A. Using a Nexus repository server on a Single-node OpenShift Cluster
While developing your cloud-native applications with Java and Maven, you may be required to build them repeatedly. You can deploy a Nexus Repository server alongside the Fabric8 Launcher tool on your Single-node OpenShift Cluster and use it to fetch artifacts from the Maven Central repository and cache them locally. This reduces the network load when building your application, and helps accelerate the build and rolling updates.
Prerequisites
- Your Single-node OpenShift Cluster set up. Follow the instructions in Install and Configure the Fabric8 Launcher Tool.
Your Single-node OpenShift Cluster configured to use at least 4096 MiB of RAM and use the required
ocCLI tool version.minishift delete # Delete the previous instance of Single-node OpenShift Cluster minishift config set memory 4096 minishift start
WarningThe procedure described below works with Minishift. It has not been tested for use with CDK.
- The Fabric8 Launcher tool deployed to your Single-node OpenShift Cluster.
- A booster application deployed to your Single-node OpenShift Cluster.
Procedure
Log in to your Single-node OpenShift Cluster instance.
oc login https://LOCAL_OPENSHIFT_URL:PORT -u developer -p developer
You can reuse the Docker daemon instance used by Single-node OpenShift Cluster to download the latest versions of the Nexus Docker container image.
eval $(minishift docker-env) docker pull openshift/jenkins-2-centos7 docker pull openshiftio/launchpad-jenkins-slave docker pull sonatype/nexus
Create a new project to contain the Nexus server. You can also use the New Project button on the Web console to do this.
oc new-project NEXUS_PROJECT_NAME
Deploy the Nexus container image.
oc new-app sonatype/nexus
Expose the service route URL of the Nexus server.
oc expose svc/nexus
Attach a persistent volume claim with a minimum size of 10 GiB to the pod running your Nexus application.
oc volumes dc/nexus --add --name 'nexus-volume-1' --type 'pvc' --mount-path '/sonatype-work/' --claim-name 'nexus-pv' --claim-size '10Gi' --overwrite
Navigate to the project containing your booster application.
oc project MY_PROJECT_NAME
Define and start a new build.
Pass in a parameter to set the value of the
MAVEN_MIRROR_URLto match the service URL of your Nexus application:NoteEnsure that the YAML template of the builder image you are using for your application has the
MAVEN_MIRROR_URLenvironment variable defined. If it does not, see the Nexus documentation for instructions on configuring your build manually before proceeding.$ oc new-build MY_APP_NAME:latest~SCM_REPOSITORY_URL \ -e MAVEN_MIRROR_URL='http://nexus.NEXUS_PROJECT_NAME:8081/nexus/content/groups/public'
Nexus comes pre-configured for the Maven Central repository, but you may need other repositories for your application. To access images provided by Red Hat, add the Red Hat JBoss Middleware Early Access Maven Repository to your Nexus instance.
Ensure that your new build is using Nexus to retrieve artifacts. Do one of the following:
-
Navigate to
http://nexus-NEXUS_PROJECT_NAME.LOCAL_OPENSHIFT_HOSTNAME/nexus/content/groups/publicto view the list of artifacts stored in your local repository. Check the log output of the build:
$ oc logs build/MY_APP_NAME-1 --follow
If your build uses Nexus to retrieve artifacts, the build log output should reference the path
http://nexus.NEXUS_PROJECT_NAME:8081/.-
Navigate to

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.