手册

Docker部署说明

741
刘溢华
2021-08-03 10:46:25
分享链接

EIP7分多服务部署   5个微服务+E ureka 服务)

docker宿主机上新建eip-docker文件夹,在该文件夹下再创建eurekaServer, potal,uc ,bpmModel,bpmRuntime,form 文件夹

docker宿主机上/home/下创建hotent目录,里面在home/hotent中创建nginx以及ucformportalruntimemodeleureka6个目录,

授权给这6个目录

cd /home/hotent/

chmod 777 *


1.1  E ure ka 服务部署

Ø 将eurekaServer.jar 和 Dockerfile 上传到eurekaServer文件夹下

Ø 创建eureka 服务镜像 eurekaServer文件夹下运行如下命令

          
          docker build -t hotent/eureka .



Ø  运行镜像容器

        
        docker run --name hotentEureka -p 28761:8761 -d hotent/eureka


Ø 浏览器访问如下图表示成功启动



1.2  UC 用户微服务部署

Ø 将uc.jar,application-uat,uc.sh,dockerfile文件上传到uc文件夹下

给所有文件授权chmod 777 *.*

application-dev.yml 可以修改配置文件 五个微服务的配置相同

如: 数据库的连接信息, redis 连接信息, activemq连接信息

注意eureka.client.service-url.defaultZone 的配置 hotentEureka eureka容器的名称

举例:



Ø 创建镜像 运行如下命令(镜像名称后记得+空格+小数点,表示获取当前目录下的dockerfile)

docker build -t hotent/uc .

uc服务的dockerfile如下:

        FROM jre:1.8
MAINTAINER heyifan "heyf@jee-soft.cn"
RUN /bin/sh -c 'mkdir -p /home/hotent && rm -f /etc/machine-id && rm -f /var/lib/dbus/machine-id && systemd-machine-id-setup'
EXPOSE 8088
ENTRYPOINT ["sh", "-c", "java -Xms1024m -Xmx4096m -jar /home/hotent/uc/uc.jar --spring.config.location=classpath:/config/application.yml,/home/hotent/uc/application-uat.yml", "&"]


出现截图内容表示创建镜像成功



Ø 创建容器 hotentUc 需要link ()

        docker run --name hotentUc -p 28088:8088 --link hotentEureka:hotentEureka -d hotent/uc


注:剩下的4个服务,dockerfile以及创建容器命令可以参考uc的,只需要修改路径、对应外部配置文件路径对应映射端口即可

1.3 P ortal 门户微服务部署

Ø portal.jar  Dockerfile application-dev.yml 配置文件上传到linux服务器


Ø 创建镜像

potal文件夹下运行下面的命令

        
        docker build -t hotent/portal .



Ø  创建容器运行如下命令

      
      docker run --name hotentPortal -p 28084:8084 -v /home/hotent:/home/hotent -d hotent/portal --link hotentEureka:hotentEureka



1.4  bpmModel 流程定义微服务部署

Ø  创建镜像

  
  
  docker build -t hotent/bpm-model .



Ø  创建容器


docker run --name hotentBpmModel -p 28087:8087 --link hotentEureka:hotentEureka -d hotent/bpm-model



启动会失败 会在容器的根目录生成hotent.mac 授权文件,需要将授权文件提供给宏天技术人员,将会提供授权文件


从容器内拷贝hotent.mac 文件提供给宏天技术人员

docker cp hotentBpmModel:/hotent.mac /usr/

宏天技术人员将提供hotent.lic文件,然后将该文件拷贝到容器内重启启动

docker cp /usr/hotent.lic hotentBpmModel:/ 

将宏天技术人员提供的hotent.lic 放到hotent.mac的同一个目录下即可

1.5  bpm Runtime 流程运行微服务部署

Ø  创建镜像

docker build -t hotent/bpm-runtime .



Ø  创建容器

docker run --name hotentBpmRuntime -p 28086:8086 --link hotentEureka:hotentEureka -d hotent/bpm-runtime


1.6  form表单服务部署

Ø 上传form.jar , application-dev.yml, Dockerfile 文件 



Ø  创建镜像

docker build -t hotent/form .



Ø  创建容器

docker run --name hotentForm -p 28082:8082 -v /home/hotent:/home/hotent -d hotent/form --link hotentEureka:hotentEureka


1.7  nginx 部署 man age front

Ø 查找外网nginx 镜像 docker search nginx


Ø 下载镜像到服务器


docker pull docker.io/nginx


 

Ø 创建容器


docker run --rm --name nginx-cool -p 8080:80 -d nginx
在本地home/hotent中创建一个nginx目录



mkdir /home/hotent/nginx
cd /home/hotent/nginx

将容器内nginx配置文件复制到本地目录上


docker cp nginx-cool:/etc/nginx .
修改目录名称


mv nginx conf
修改conf/conf.d中的default.conf,内容如下



server {
        listen       8280;
        server_name  127.0.0.1;
        
        location / {
            root   /usr/share/nginx/html;
            index index.html;
            error_page 404 /fvue/index.html;
        }
        
        error_page 404 /404.html;
            location = /40x.html {
        }
        error_page 500 502 503 504 /50x.html;
             location = /50x.html {
        }
	location /fvue {
	    root   /usr/share/nginx/html;
            index  index.html;
	    try_files $uri $uri/ /fvue/index.html;
	}
        location /mvue {
	    root   /usr/share/nginx/html;
            index  index.html;
	    try_files $uri $uri/ /mvue/index.html;
	}
        location /mobilevue {
	    root   /usr/share/nginx/html;
            index  index.html;
	    try_files $uri $uri/ /mobilevue/index.html;
	}
  }
在/home/hotent/nginx/中新建目录html



mkdir /home/hotent/nginx/html
chmod 777 /home/hotent/nginx/html


将提供的前端文件上传到这个目录下

停止容器


docker stop nginx-cool


重新运行容器,将本地目录挂载到容器内部


cd /home/hotent/nginx
docker run --name nginx-cool -v "$PWD/html":/usr/share/nginx/html -v "$PWD/conf":/etc/nginx -p 8280:8280 -d nginx
注意: 上传的mvue 和 fvue 以及mobilevue中各有一个sso.js 需要修改为对应各个微服务的请求的端口,管理端、应用端、手机端需要将端口号改为82


访问地址:
管理端ip:8280/mvue
应用端ip:8280/fvue
手机端ip:8280/mobilevue

发表评论
评论通过审核后显示。