spring boot docker构建

一、利用spring-boot-maven-plugin,但是缺少灵活配置。

      <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.5.6</version>
                <configuration>
                    <docker>
                        <host>tcp://xxxxxx:2375</host>
                        <tlsVerify>false</tlsVerify>
                        <publishRegistry>
                            <username>xxx</username>
                            <password>xxx</password>
                            <url>xxxxx</url>
                            <email>user@example.com</email>
                        </publishRegistry>
                    </docker>
                    <image>
                        <name>xxxxx/data-apps/${project.artifactId}:${project.version}</name>
                        <publish>false</publish>
                    </image>
                </configuration>
            </plugin>

利用docker-maven-plugin也可以完成。

此外,建议使用IDEA的docker插件,更加灵活。

 

二、Dockerfile用于构建镜像,docker-compose用于容器编排(不用于镜像构建)

三、.dockerignore用于指定发送到docker server的构建内容,同.gitignore类似

具体将构建内容发送到docker目录下的tmp

通过跟踪 tmp中的内容,发现.dockerignore **/* 不能屏蔽同.dockerignore同级文件,比如pom.xml、README.md,需要单独列到.dockerignore中

 

四、logback-spring

1. 解决IS_UNDEFINED
改logback-sb.xml logging.config

2. SizeAndTimeBasedRollingPolicy fileNamePattern ${log.path}/%d{yyyy-MM,aux}/${app.name}_info.%d{yyyy-MM-dd-HH-mm}.%i.log

Note that only one %d token can be primary, all other tokens must be marked as auxiliary by passing the 'aux' parameter.

 

posted on 2022-07-15 15:42  -赶鸭子上架-  阅读(120)  评论(0编辑  收藏  举报