64-maven插件将jar包部署到docker容器

1. 插件

io.fabric8
docker-maven-plugin
0.39.1

2. 根目录pom的插件管理配置


    
        
                    io.fabric8
                    docker-maven-plugin
                    0.39.1
                    
                        
                        tcp://192.168.207.109:2375

                        
                            
                                
                                ybss-cloud/${project.artifactId}:${project.version}
                                ${project.artifactId}
                                
                                    
                                    ${project.basedir}/Dockerfile
                                    true
                                    true
                                    

                                        
                                        host
                                        true
                                        true
                                    
                                

                                
                                    alias
                                    
                                        ybss_default
                                        ${project.artifactId}-net
                                    
                                    
                                        ${docker.port}
                                    
                                    true
                                
                            
                        
                    
                    
                        
                            docker-exec
                            
                            install
                            
                                build
                                run
                            
                        
                    
                
    

3. 子模块的pom配置

    
        com.xxx.gateway.GatewayApplication
        18080:8080
    
    
        
            
                io.fabric8
                docker-maven-plugin
            
        
    

4. Dockerfile内容

Dockerfile文件位置与pom.xml同级

FROM openjdk:8-jre

MAINTAINER xxx

WORKDIR /opt

VOLUME /opt/logs

ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV TZ Asia/Shanghai

ADD target/*-gateway-1.0.jar app.jar
ADD target/lib lib

EXPOSE 8080

ENTRYPOINT ["java", "-Dfile.encoding=utf-8", "-Xms1200m", "-Xmx1200m", "-XX:MetaspaceSize=128m", "-XX:MaxMetaspaceSize=128m", "-Xss512K", "-jar", "/opt/app.jar"]

5. 其他子模块类似

6. 部署

mvn clean
mvn package
mvn docker:build
mvn docker:run

你可能感兴趣的:(后端)