Dockerfile

This commit is contained in:
shikong 2024-12-09 22:41:50 +08:00
parent cd5e19a184
commit 7e5e258f77
Signed by: Shikong
GPG Key ID: BD85FF18B373C341
6 changed files with 194 additions and 0 deletions

17
package-docker.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# 用于缓存打包过程下载的依赖
mkdir repository
curDir=`pwd`
docker run --name maven --rm \
-v ${curDir}:/usr/src/mymaven \
-v ${curDir}/repository:/root/.m2/repository \
-v ${curDir}/settings.xml:/usr/share/maven/ref/settings.xml \
-v /etc/docker/daemon.json:/etc/docker/daemon.json -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker \
-w /usr/src/mymaven \
maven:3.9.3-eclipse-temurin-17-alpine \
mvn clean package -DskipTests -Pdocker
docker save skcks.cn/wx-mp-service -o wx-mp-service.image
docker save skcks.cn/wx-miniapp-service -o wx-miniapp-service.image
docker save skcks.cn/admin-web-service -o admin-web-service.image
ls -lh *.image

View File

@ -0,0 +1,13 @@
FROM eclipse-temurin:17-jre-alpine
MAINTAINER Shikong <919411476@qq.com>
ENV HOME_PATH /opt/wx-docking-platform/
RUN mkdir -p $HOME_PATH
WORKDIR $HOME_PATH
ADD target/admin-web-service.jar /opt/wx-docking-platform/admin-web-service.jar
EXPOSE 18880
ENTRYPOINT ["java", "-jar","/opt/wx-docking-platform/admin-web-service.jar"]

View File

@ -59,6 +59,33 @@
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${docker.maven.plugin.version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>${skip.docker}</skip>
<repository>skcks.cn/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
@ -72,6 +99,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
FROM eclipse-temurin:17-jre-alpine
MAINTAINER Shikong <919411476@qq.com>
ENV HOME_PATH /opt/wx-docking-platform/
RUN mkdir -p $HOME_PATH
WORKDIR $HOME_PATH
ADD target/wx-miniapp-service.jar /opt/wx-docking-platform/wx-miniapp-service.jar
EXPOSE 18882
ENTRYPOINT ["java", "-jar","/opt/wx-docking-platform/wx-miniapp-service.jar"]

View File

@ -0,0 +1,13 @@
FROM eclipse-temurin:17-jre-alpine
MAINTAINER Shikong <919411476@qq.com>
ENV HOME_PATH /opt/wx-docking-platform/
RUN mkdir -p $HOME_PATH
WORKDIR $HOME_PATH
ADD target/wx-mp-service.jar /opt/wx-docking-platform/wx-mp-service.jar
EXPOSE 18881
ENTRYPOINT ["java", "-jar","/opt/wx-docking-platform/wx-mp-service.jar"]

106
pom.xml
View File

@ -52,8 +52,114 @@
<springdoc.version>2.7.0</springdoc.version>
<lombok.version>1.18.36</lombok.version>
<org.mapstruct.version>1.6.3</org.mapstruct.version>
<docker.maven.plugin.version>1.4.13</docker.maven.plugin.version>
</properties>
<profiles>
<profile>
<id>jar</id>
<properties>
<skip.docker>true</skip.docker>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>docker</id>
<properties>
<skip.docker>false</skip.docker>
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
</profile>
<!--<profile>-->
<!-- <id>ossrh</id>-->
<!-- <properties>-->
<!-- <skip.docker>true</skip.docker>-->
<!-- </properties>-->
<!-- <activation>-->
<!-- <activeByDefault>false</activeByDefault>-->
<!-- </activation>-->
<!-- <build>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.sonatype.central</groupId>-->
<!-- <artifactId>central-publishing-maven-plugin</artifactId>-->
<!-- <version>0.4.0</version>-->
<!-- <extensions>true</extensions>-->
<!-- <configuration>-->
<!-- <publishingServerId>ossrh</publishingServerId>-->
<!-- <centralBaseUrl>https://central.sonatype.com</centralBaseUrl>-->
<!-- <tokenAuth>true</tokenAuth>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-source-plugin</artifactId>-->
<!-- <version>2.2.1</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>attach-sources</id>-->
<!-- <goals>-->
<!-- <goal>jar-no-fork</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-javadoc-plugin</artifactId>-->
<!-- <version>2.9.1</version>-->
<!-- <configuration>-->
<!-- <additionalparam>-Xdoclint:none</additionalparam>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>attach-javadocs</id>-->
<!-- <goals>-->
<!-- <goal>jar</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
<!-- <version>1.5</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>sign-artifacts</id>-->
<!-- <phase>verify</phase>-->
<!-- <goals>-->
<!-- <goal>sign</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <keyname>2FA8C646FBB668DAF3E6B08CBD85FF18B373C341</keyname>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
<!-- <distributionManagement>-->
<!-- <snapshotRepository>-->
<!-- <id>ossrh</id>-->
<!-- <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>-->
<!-- </snapshotRepository>-->
<!-- <repository>-->
<!-- <id>ossrh</id>-->
<!-- <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>-->
<!-- </repository>-->
<!-- </distributionManagement>-->
<!--</profile>-->
</profiles>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>