feat:添加dockerfile项目构建

This commit is contained in:
haoxr 2021-05-19 20:46:55 +08:00
parent f5e99abd41
commit 8fc8468219
5 changed files with 36 additions and 49 deletions

View File

@ -0,0 +1,6 @@
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD target/ums-boot.jar ums-boot.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/ums-boot.jar"]
EXPOSE 8100
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \&& echo 'Asia/Shanghai' >/etc/timezone

View File

@ -104,6 +104,7 @@
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@ -112,45 +113,31 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<!--执行mvn package,即执行 mvn clean package docker:build-->
<!-- <execution>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
<!-- <goal>build</goal>-->
</goals>
</execution>-->
</execution>
</executions>
<configuration>
<!-- 镜像名称 -->
<imageName>${project.artifactId}</imageName>
<!-- 指定标签 -->
<!--指定标签-->
<imageTags>
<imageTag>latest</imageTag>
</imageTags>
<!-- 基础镜像-->
<baseImage>openjdk:8-jdk-alpine</baseImage>
<!-- 切换到容器工作目录-->
<workdir>/</workdir>
<entryPoint>["java","-jar","${project.build.finalName}.jar"]</entryPoint>
<!-- 指定远程 Docker API地址 -->
<dockerHost>https://c.youlai.tech:2376</dockerHost>
<!-- 指定tls证书的目录 -->
<dockerCertPath>C:\cert\docker\c.youlai.tech</dockerCertPath>
<!-- 复制 jar包到docker容器指定目录-->
<!-- 指定 Dockerfile 路径-->
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<forceTags>true</forceTags>
<resources>
<resource>
<targetPath>/</targetPath>
<!-- 用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
<directory>${project.build.directory}</directory>
<!-- 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 -->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
@ -158,4 +145,5 @@
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,6 @@
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD target/admin-boot.jar admin-boot.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/admin-boot.jar"]
EXPOSE 8100
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \&& echo 'Asia/Shanghai' >/etc/timezone

View File

@ -101,6 +101,7 @@
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@ -109,45 +110,31 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions>
<!--执行mvn package,即执行 mvn clean package docker:build-->
<!-- <execution>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
<!-- <goal>build</goal>-->
</goals>
</execution>-->
</execution>
</executions>
<configuration>
<!-- 镜像名称 -->
<imageName>${project.artifactId}</imageName>
<!-- 指定标签 -->
<!--指定标签-->
<imageTags>
<imageTag>latest</imageTag>
</imageTags>
<!-- 基础镜像-->
<baseImage>openjdk:8-jdk-alpine</baseImage>
<!-- 切换到容器工作目录-->
<workdir>/</workdir>
<entryPoint>["java","-jar","${project.build.finalName}.jar"]</entryPoint>
<!-- 指定远程 Docker API地址 -->
<dockerHost>https://f.youlai.tech:2376</dockerHost>
<!-- 指定tls证书的目录 -->
<dockerCertPath>C:\cert\docker\f.youlai.tech</dockerCertPath>
<!-- 复制 jar包到docker容器指定目录-->
<!-- 指定 Dockerfile 路径-->
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<forceTags>true</forceTags>
<resources>
<resource>
<targetPath>/</targetPath>
<!-- 用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
<directory>${project.build.directory}</directory>
<!-- 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 -->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>

View File

@ -20,7 +20,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
" left join sys_dept d on u.dept_id= d.id " +
" left join sys_user_role ur on u.id=ur.user_id " +
" left join sys_role r on ur.role_id=r.id " +
" where deleted != 1 " +
" where u.deleted != 1 " +
" <if test ='user.username!=null and user.username.trim() neq \"\"'>" +
" and u.username like concat('%',#{user.username},'%')" +
" </if>" +