美文网首页springboot
idea集成docker部署springboot项目

idea集成docker部署springboot项目

作者: 王龙_ce74 | 来源:发表于2019-10-04 18:39 被阅读0次

idea集成docker部署springboot项目

宿主机器/服务器docker配置

  • 配置docker远程连接端口
vi /usr/lib/systemd/system/docker.service

找到 ExecStart,在最后面添加 -H tcp://0.0.0.0:2375


image.png
  • 重启docker
systemctl daemon-reload
systemctl start docker
  • 防火墙开放端口

idea配置

  • 安装docker插件


    image.png

    *配置远程docker访问


    image.png
  • 配置docker打包plugin
<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.2.9</version>
                <configuration>
                    <imageName>missj/agency_admin</imageName>
                    <dockerDirectory>src/main/docker</dockerDirectory>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>src/main/docker</directory>
                            <include>agency_admin.jar</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <copy todir="src/main/docker" file="target/${project.artifactId}-${project.version}.${project.packaging}"></copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
  • 编辑Dockerfile文件
FROM openjdk:8-jdk-alpine
ADD *.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
  • docker启动设置


    image.png

相关文章

网友评论

    本文标题:idea集成docker部署springboot项目

    本文链接:https://www.haomeiwen.com/subject/ypgiuctx.html