Docker部署nexus

Resources:

中心仓库索引,好大的文件。

nexus-2.15.1-02-bundle.tar.gz
openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz
 

Dockerfile:

FROM centos:centos7

MAINTAINER PCM

ADD openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz nexus-2.15.1-02-bundle.tar.gz /usr/local/

RUN sed -i 's/#RUN_AS_USER=/RUN_AS_USER=root/' /usr/local/nexus-2.15.1-02/bin/nexus

ENV JAVA_HOME=/usr/local/java-se-8u41-ri/ \
    PATH=$PATH:/usr/local/java-se-8u41-ri/bin

EXPOSE 8081

CMD /usr/local/nexus-2.15.1-02/bin/nexus start && tail -f /usr/local/nexus-2.15.1-02/logs/wrapper.log


 

docker run:

docker run --name=nexus -d -p8081:8081 -v /usr/local/sonatype-work/:/usr/local/sonatype-work/ --privileged=true  549414168/nexus:v1

运行之后覆盖中心仓库索引,之后重启。

一直无法有索引和docker容器内权限有关系,真坑。

总算是配置成功。

相关资料:

nexus2下载:

Downloadhttps://help.sonatype.com/repomanager2/download#Download-NexusRepositoryManager2OSS索引地址:

Central Repository: .index

nexus-maven-repository-index.gz                   2022-07-13 22:041615748068      
nexus-maven-repository-index.gz.md5               2022-07-13 22:04        32      
nexus-maven-repository-index.gz.sha1              2022-07-13 22:04        40      
nexus-maven-repository-index.properties           2022-07-13 22:04      1130      

解压索引工具:indexer-cli-5.1.1.jar

Maven Central Repository Search

wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz
wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.properties
wget https://repo.maven.apache.org/maven2/org/apache/maven/indexer/indexer-cli/5.1.1/indexer-cli-5.1.1.jar
wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz.md5
wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz.sha1


 

导入本地仓库架包:

1.编脚本mavenimport.sh

#!/bin/bash
 
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
while getopts ":r:u:p:" opt; do
    case $opt in
        r) REPO_URL="$OPTARG"
        ;;
        u) USERNAME="$OPTARG"
        ;;
        p) PASSWORD="$OPTARG"
        ;;
    esac
done
 
find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

文件保存到仓库根路径。

2.启动脚本

./mavenimport.sh -u admin -p admin123 -r http://192.168.2.3:8081/nexus/content/repositories/myrep/

导入后项目测试

1.maven。setting设置

D:\apache-maven-3.6.0\test
    
    
    
    
    
        
            releases
            admin
            admin123
        

        
            snapshots
            admin
            admin123
        
    

    
        
            
            dev
            
                
                    
                    nexus
                    
                    http://192.168.2.3:8081/nexus/content/groups/public/
                    
                    
                        true
                    
                    
                    
                        true
                    
                
            
            
                
                
                    
                    public
                    Public Repositories
                    http://192.168.2.3:8081/nexus/content/groups/public/
                
            
        
    
    
        dev
    

2.项目使用pom.xml


        
            ···
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    true
                
            
            
                
                org.apache.maven.plugins
                maven-surefire-plugin
                
                    true
                
            
            
            ······
            
            
                org.apache.maven.plugins
                maven-deploy-plugin
            
        
    

    
        
            releases
            http://192.168.2.3:8081/nexus/content/repositories/releases/
        
        
            snapshots
            http://192.168.2.3:8081/nexus/content/repositories/snapshots/
        
    

温馨提示:

此处注意:pom中的这部分新增URL和ID与setting中的对应。

不新增这部分也可以使用。

你可能感兴趣的:(总结,docker,服务器,linux)