mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
feat:idea集成docker-maven-plugin实现一键部署
This commit is contained in:
parent
3bf0ec8cae
commit
4bba4c5747
2
pom.xml
2
pom.xml
@ -29,7 +29,6 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<docker.image.prefix>youlai</docker.image.prefix>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
@ -109,4 +108,5 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
|
@ -99,4 +99,57 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</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>http://101.132.25.57:2375</dockerHost>
|
||||
|
||||
<!-- 复制 jar包到docker容器指定目录-->
|
||||
<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>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
20
youlai-auth/src/main/resources/bootstrap-dev.yml
Normal file
20
youlai-auth/src/main/resources/bootstrap-dev.yml
Normal file
@ -0,0 +1,20 @@
|
||||
server:
|
||||
port: 8000
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: youlai-auth
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: http://localhost:8848
|
||||
config:
|
||||
# docker启动nacos-server需要配置
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
group: DEFAULT_GROUP
|
||||
prefix: ${spring.application.name}
|
||||
wx:
|
||||
miniapp:
|
||||
appid: wx99a151dc43d2637b
|
||||
secret: a09605af8ad29ca5d18ff31c19828f37
|
20
youlai-auth/src/main/resources/bootstrap-prod.yml
Normal file
20
youlai-auth/src/main/resources/bootstrap-prod.yml
Normal file
@ -0,0 +1,20 @@
|
||||
server:
|
||||
port: 8000
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: youlai-auth
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: http://c.youlai.store:8848
|
||||
config:
|
||||
# docker启动nacos-server需要配置
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
group: DEFAULT_GROUP
|
||||
prefix: ${spring.application.name}
|
||||
wx:
|
||||
miniapp:
|
||||
appid: wx99a151dc43d2637b
|
||||
secret: a09605af8ad29ca5d18ff31c19828f37
|
@ -1,20 +1,3 @@
|
||||
server:
|
||||
port: 8000
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: youlai-auth
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: http://localhost:8848
|
||||
config:
|
||||
# docker启动nacos-server需要配置
|
||||
server-addr: ${spring.cloud.nacos.discovery.server-addr}
|
||||
file-extension: yaml
|
||||
group: DEFAULT_GROUP
|
||||
prefix: ${spring.application.name}
|
||||
wx:
|
||||
miniapp:
|
||||
appid: wx99a151dc43d2637b
|
||||
secret: a09605af8ad29ca5d18ff31c19828f37
|
||||
profiles:
|
||||
active: dev
|
||||
|
@ -1,6 +0,0 @@
|
||||
FROM openjdk:8-jdk-alpine
|
||||
VOLUME /tmp
|
||||
ARG JAR_FILE
|
||||
ADD target/${JAR_FILE} app.jar
|
||||
EXPOSE 9999
|
||||
ENTRYPOINT ["java","-jar","/app.jar"]
|
@ -13,6 +13,10 @@
|
||||
|
||||
<artifactId>youlai-gateway</artifactId>
|
||||
|
||||
<properties>
|
||||
<youlai.version>1.0.0-SNAPSHOT</youlai.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.youlai</groupId>
|
||||
@ -59,47 +63,56 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<youlai.version>1.0.0-SNAPSHOT</youlai.version>
|
||||
<dockerfile-maven-version>1.4.13</dockerfile-maven-version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>dockerfile-maven-plugin</artifactId>
|
||||
<version>${dockerfile-maven-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default</id>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<repository>${project.artifactId}</repository>
|
||||
<tag>latest</tag>
|
||||
<buildArgs>
|
||||
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
<!-- 镜像名称 -->
|
||||
<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>http://101.37.69.49:2375</dockerHost>
|
||||
|
||||
<!-- 复制 jar包到docker容器指定目录-->
|
||||
<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>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -1,3 +1,3 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
|
Loading…
Reference in New Issue
Block a user