本地项目上传到Harbor

本地项目上传到Harbor,第1张

本地项目上传到Harbor 一、Harbor服务器配置

vi /lib/systemd/system/docker.service

修改配置

ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375

二、Maven配置

       
       harbor-regisry
       
       admin
       
       Harbor12345
	   
            admin@example.com
      
   
三、测试项目

项目结构

EurekaserverApplication

package com.example.eurekaserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaserverApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaserverApplication.class, args);
    }

}

Dockerfile

#定制的镜像基于java(这里java是jdk镜像,latest的版本)镜像
FROM harbor.register/jdk/jdk1.8:v1
#指定镜像创建者信息
MAINTAINER zhuzq
#其效果是在主机  /var/lib/docker  目录下创建了一个临时文件,并链接到容器的 /tmp
VOLUME /tmp
#把eurekaserver.jar 拷贝到容器eurekaserver.jar
ADD eurekaserver.jar  eurekaserver.jar
#在容器启动程序
ENTRYPOINT ["java","-jar","/eurekaserver.jar"]

application.yaml

server:
  port: 8000

eureka:
  instance:
    hostname: localhost  # 指定Eureka主机
  client:
    register-with-eureka: false   # 指定当前主机是否向Eureka服务器进行注册
    fetch-registry: false    # 指定当前主机是否要从Eurka服务器下载服务注册列表
    service-url:   # 服务暴露地址
      defaultZone: http://localhost:8000/eureka
  #     defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka

#  server:
#    enable-self-preservation: false    # 关闭自我保护

pom.xml



    4.0.0

    com.example
    eurekaserver
    v1
    jar

    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.7.RELEASE
         
    

    
        1.8
        Greenwich.SR1
    

    

        
            org.springframework.cloud
            spring-cloud-starter-netflix-eureka-server
        
        
            org.springframework.boot
            spring-boot-autoconfigure
        


       
      


    

    
        
            
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
            
        
    

    
        eurekaserver
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            

            
                com.spotify
                docker-maven-plugin
                1.0.0

                
                    
                    harbor.register/eurekaserver/${project.artifactId}:${project.version}
                    
                    ${project.basedir}/src/main/resources/docker
                    
                    harbor.register/jdk/jdk1.8:v1
                    true
                    
                    harbor-regisry
                    https://harbor.register/
                    
                        
                        
                            /
                                                        
                            ${project.build.directory}
                                                       
                            ${project.build.finalName}.jar
                        
                    
                    
                    http://harbor.register:2375
                

            

        
    

四、测试

maven-lifecycle-package 

maven-plugings-docker

harbor服务器

 harbor私服仓库

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5708879.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存