Setting up a Nexus

Guide to Installing and Using Nexus

hpyYh avatar
  • hpyYh
  • 2 min read

Nexus Guide

Background

we previously utilized the GitLab Package Registry to maintain pipeline consistency, but we are considering a transition to Nexus due to the following limitations

  • Paid Proxy Functionality
  • Unstable Backup/Restore Features
  • Lack of a GUI-based Upload Feature

Quick Start Guide

  1. Nexus installation

  2. Nexus initialization

    • initial admin password check
    docker exec -it nexus cat /nexus-data/admin.password
    > 53f2fc25-3685-4eb5-85e2-a7e0b47f057a
    
    • admin password change
    curl -u admin:53f2fc25-3685-4eb5-85e2-a7e0b47f057a -X PUT "http://localhost:8081/service/rest/v1/security/users/admin/change-password" \
    -H "Content-Type: text/plain" \
    -d "adminadmin"
    
    • anonymous access enable
    curl -u admin:adminadmin -X PUT "http://localhost:8081/service/rest/v1/security/anonymous" \
    -H "Content-Type: application/json" \
    -d '{
    "enabled": true,
    "userId": "anonymous",
    "realmName": "NexusAuthorizingRealm"
    }'
    
    • egov create repository
    curl -u admin:adminadmin -X POST 'http://localhost:8081/service/rest/v1/repositories/maven/proxy' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{
    "name": "egov-proxy",
    "online": true,
    "storage": {
    "blobStoreName": "default",
    "strictContentTypeValidation": true
    },
    "proxy": {
    "remoteUrl": "https://maven.egovframe.go.kr/maven/",
    "contentMaxAge": 1440,
    "metadataMaxAge": 1440
    },
    "negativeCache": {
    "enabled": true,
    "timeToLive": 1440
    },
    "httpClient": {
    "autoBlock": true,
    "blocked": false
    },
    "maven": {
    "versionPolicy": "RELEASE",
    "layoutPolicy": "STRICT",
    "contentDisposition": "ATTACHMENT"
    }
    }'
    
    • npm create repository
    curl -u admin:adminadmin -X POST "http://localhost:8081/service/rest/v1/repositories/npm/proxy" \
     -H "Content-Type: application/json" \
     -d '{
     "name": "npm-proxy",
     "online": true,
     "storage": {
     "blobStoreName": "default",
     "strictContentTypeValidation": true
     },
     "proxy": {
     "remoteUrl": "https://registry.npmjs.org",
     "contentMaxAge": 1440,
     "metadataMaxAge": 1440
     },
     "negativeCache": {
     "enabled": true,
     "timeToLive": 1440
     },
     "httpClient": {
     "autoBlock": true,
     "blocked": false
     }
     }'
    
  3. backend proxy apply

    • gradle cache clear ( mac ex : rm -rf ~/.gradle/caches/ )
    • build.gradle modify
    repositories {
       maven {
            url "http://localhost:8081/repository/maven-public/"
            allowInsecureProtocol = true
        }
    
        maven {
            url "http://localhost:8081/repository/egov-proxy/"
            allowInsecureProtocol = true
        }
    }
    
  4. frontend proxy apply

    npm config set registry http://localhost:8081/repository/npm-proxy/
    

    npm install & npm run build

  5. backup

    • To migrate proxied or manually registered libraries to the production environment, you can simply overwrite the blobs and db folders within nexus-data in their entirety.
  6. browser

    • http://localhost:8081/

Comment

comments powered by Disqus
hpyYh

Written by : hpyYh

Continue Reading