zoukankan      html  css  js  c++  java
  • Spring Cloud项目部署(三)使用maven插件上传docker镜像的相关配置

    1.本地window系统安装maven

    通过cmd中的mvn命令将项目镜像上传至服务器的docker中。(参考网上的window下的maven安装和配置)

    2.修改本机的系统环境参数。

    测试服务器地址192.168.0.170

    3.各项目的pom文件修改

    添加以下

    <!-- tag::plugin[] -->
    <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <configuration>
            <imageName>shi/${project.artifactId}</imageName>  //镜像名称
            <dockerDirectory>src/main/docker</dockerDirectory>
            <resources>
                <resource>
                    <targetPath>/</targetPath>
                    <directory>${project.build.directory}</directory>
                    <include>${project.build.finalName}.jar</include>
                </resource>
            </resources>
        </configuration>
    </plugin>
    <!-- end::plugin[] -->

    4.eureka的配置文件

    # 注册中心

    server:
      port: 8761

    eureka:
    instance:
    # 优先使用IP地址方式进行注册服务
    prefer-ip-address: true

    client:
    #是否将eureka自身作为应用注册到eureka注册中心
    registerWithEureka: false
    fetchRegistry: false # 不需要检索服务
    serviceUrl:
    defaultZone: http://localhost:${server.port}/eureka/

    spring:
    application:
    name: eureka-server

    5.其他项目的配置文件修改

    #指定注册中心地址
    eureka:
    client:
    serviceUrl:
    defaultZone: http://eureka-server:8761/eureka/
    instance:
    prefer-ip-address: true  

      

    6.生成jar包

    7.添加Dockerfile文件

    所有项目的下添加Dockerfile文件,结构参考

    8.Dockerfile文件内容

    FROM java:8
    VOLUME /tmp
    #jar包名
    ADD eureka-server-1.0.0.jar app.jar  //注意修改,此处根据mvn install生成的jar包进行修改
    ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
    EXPOSE 8761  //端口号,不同的项目注意修改
  • 相关阅读:
    UVALive 5983 MAGRID DP
    2015暑假训练(UVALive 5983
    poj 1426 Find The Multiple (BFS)
    poj 3126 Prime Path (BFS)
    poj 2251 Dungeon Master 3维bfs(水水)
    poj 3278 catch that cow BFS(基础水)
    poj3083 Children of the Candy Corn BFS&&DFS
    BZOJ1878: [SDOI2009]HH的项链 (离线查询+树状数组)
    洛谷P3178 [HAOI2015]树上操作(dfs序+线段树)
    洛谷P3065 [USACO12DEC]第一!First!(Trie树+拓扑排序)
  • 原文地址:https://www.cnblogs.com/shiblog/p/11541698.html
Copyright © 2011-2022 走看看