Loading

Sonatype Nexus Repository Pro本地软件制品仓库

最终效果

Nexus私服仓库,版本:3.91.1-04
image

背景

支持多种制品类型的成熟软件很少,例如Jfrog Artifactory、Nexus或者是针对容器镜像制品的Harbor,如果要在本地构建一套完整的制品仓库(包含镜像功能)非常不容易,学习中我们来使用Sonatype Nexus Repostiry Pro版本来演示,支持以下的基本功能:

  1. 制品管理
  2. 本地镜像源(apt、yum、pypi、maven、docker)

部署方法

有几种方式来进行部署,我们先下载存档备用(如果你不需要特殊功能,也可以不下载)

1. (可选)官网获取下载地址

访问https://help.sonatype.com/en/download-archives---repository-manager-3.html找到对应需要的版本下载链接,比如

wget https://download.sonatype.com/nexus/3/nexus-3.91.1-04-linux-x86_64.tar.gz
wget https://download.sonatype.com/nexus/3/nexus-3.91.1-04-linux-aarch_64.tar.gz

2. 使用Docker进行部署

编写docker-compose.yaml

services:
  nexus:
    image: sonatype/nexus3:3.91.1-ubi
    restart: always
    ports:
      - "8081:8081"
    environment:
      - INSTALL4J_ADD_VM_PARAMS=-Xms2703m -Xmx2703m -XX:MaxDirectMemorySize=2703m -Djava.util.prefs.userRoot=/nexus-data/javaprefs
      - NEXUS_DATASTORE_ENABLED=true
      - NEXUS_DATASTORE_NEXUS_JDBCURL=jdbc:postgresql://postgres:5432/nexus
      - NEXUS_DATASTORE_NEXUS_USERNAME=nexus
      - NEXUS_DATASTORE_NEXUS_PASSWORD=nexus_password
      - EXTRA_JAVA_OPTS=-Dnexus.blobstore.s3.multipartUploadDisabled=true
    volumes:
      - nexus-data:/nexus-data
      - ./sonatype-nexus-repository-3.91.1-04.jar:/opt/sonatype/nexus/bin/sonatype-nexus-repository-3.91.1-04.jar:ro # 仅特殊功能需要在这部分挂在外置的jar文件
    depends_on:
      - postgres

  postgres:
    image: bitnami/postgresql:latest
    restart: always
    environment:
      - POSTGRESQL_DATABASE=nexus
      - POSTGRESQL_USERNAME=nexus
      - POSTGRESQL_PASSWORD=nexus_password
    volumes:
      - postgres-data:/bitnami/postgresql

volumes:
  nexus-data:
  postgres-data:

networks:
  default:
    name: nexus-network

3. 启动

使用docker compose up -d即可进行部署,稍等后打开浏览器访问8081端口设置密码即可

参考资料

  1. https://www.cnblogs.com/machangwei-8/p/18362053
  2. https://help.sonatype.com/en/administration-best-practices.html
  3. https://wiki.eryajf.net/pages/1815.html
  4. https://www.cnblogs.com/morang/p/devops-nexus3-nuget-docker-install-use.html
  5. https://yufanonsoftware.me/posts/ci-with-self-hosted-jenkins-gogs-and-nexus-registry
  6. https://anegio.com/posts/2024/nexus-encryption-key/
posted @ 2026-05-08 23:55  codesucks  阅读(53)  评论(0)    收藏  举报