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> <build>
<finalName>${artifactId}</finalName> <finalName>${artifactId}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -112,45 +113,31 @@
<plugin> <plugin>
<groupId>com.spotify</groupId> <groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId> <artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version> <version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions> <executions>
<!--执行mvn package,即执行 mvn clean package docker:build--> <execution>
<!-- <execution>
<id>build-image</id> <id>build-image</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>build</goal> <!-- <goal>build</goal>-->
</goals> </goals>
</execution>--> </execution>
</executions> </executions>
<configuration> <configuration>
<!-- 镜像名称 -->
<imageName>${project.artifactId}</imageName> <imageName>${project.artifactId}</imageName>
<!-- 指定标签 --> <!--指定标签-->
<imageTags> <imageTags>
<imageTag>latest</imageTag> <imageTag>latest</imageTag>
</imageTags> </imageTags>
<!-- 基础镜像--> <!-- 指定 Dockerfile 路径-->
<baseImage>openjdk:8-jdk-alpine</baseImage> <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<forceTags>true</forceTags>
<!-- 切换到容器工作目录-->
<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容器指定目录-->
<resources> <resources>
<resource> <resource>
<targetPath>/</targetPath> <targetPath>/</targetPath>
<!-- 用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
<directory>${project.build.directory}</directory> <directory>${project.build.directory}</directory>
<!-- 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 -->
<include>${project.build.finalName}.jar</include> <include>${project.build.finalName}.jar</include>
</resource> </resource>
</resources> </resources>
@ -158,4 +145,5 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </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> <build>
<finalName>${artifactId}</finalName> <finalName>${artifactId}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -109,45 +110,31 @@
<plugin> <plugin>
<groupId>com.spotify</groupId> <groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId> <artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version> <version>1.2.2</version>
<!--将插件绑定在某个phase执行-->
<executions> <executions>
<!--执行mvn package,即执行 mvn clean package docker:build--> <execution>
<!-- <execution>
<id>build-image</id> <id>build-image</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>build</goal> <!-- <goal>build</goal>-->
</goals> </goals>
</execution>--> </execution>
</executions> </executions>
<configuration> <configuration>
<!-- 镜像名称 -->
<imageName>${project.artifactId}</imageName> <imageName>${project.artifactId}</imageName>
<!-- 指定标签 --> <!--指定标签-->
<imageTags> <imageTags>
<imageTag>latest</imageTag> <imageTag>latest</imageTag>
</imageTags> </imageTags>
<!-- 基础镜像--> <!-- 指定 Dockerfile 路径-->
<baseImage>openjdk:8-jdk-alpine</baseImage> <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<forceTags>true</forceTags>
<!-- 切换到容器工作目录-->
<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容器指定目录-->
<resources> <resources>
<resource> <resource>
<targetPath>/</targetPath> <targetPath>/</targetPath>
<!-- 用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
<directory>${project.build.directory}</directory> <directory>${project.build.directory}</directory>
<!-- 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 -->
<include>${project.build.finalName}.jar</include> <include>${project.build.finalName}.jar</include>
</resource> </resource>
</resources> </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_dept d on u.dept_id= d.id " +
" left join sys_user_role ur on u.id=ur.user_id " + " left join sys_user_role ur on u.id=ur.user_id " +
" left join sys_role r on ur.role_id=r.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 \"\"'>" + " <if test ='user.username!=null and user.username.trim() neq \"\"'>" +
" and u.username like concat('%',#{user.username},'%')" + " and u.username like concat('%',#{user.username},'%')" +
" </if>" + " </if>" +