Browse Source

测试打动打包

zdd 2 years ago
parent
commit
8a18d79c13
5 changed files with 69 additions and 6 deletions
  1. 1 0
      .gitignore
  2. 64 2
      pom.xml
  3. 1 1
      src/.drone.yml
  4. 2 2
      src/Dockerfile
  5. 1 1
      src/run.sh

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 /.idea
+/target

+ 64 - 2
pom.xml

@@ -5,8 +5,8 @@
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>org.example</groupId>
-    <artifactId>code_build_test</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <artifactId>code-test</artifactId>
+    <version>1.0.0</version>
 
     <!--导入springboot 父工程-->
     <parent>
@@ -21,4 +21,66 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
     </dependencies>
+
+    <profiles>
+        <profile>
+            <id>dev</id>
+            <!--默认激活当前配置-->
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <properties>
+                <profiles.active>dev</profiles.active>
+                <!-- Docker 配置 -->
+                <docker.dockerHost>http://172.16.90.64:22375</docker.dockerHost>
+                <docker.serviceId>DockerHub</docker.serviceId>
+                <docker.image.version>1.0.0</docker.image.version>
+            </properties>
+        </profile>
+        <profile>
+            <id>pro</id>
+            <properties>
+                <profiles.active>pro</profiles.active>
+                <!-- Docker 配置 -->
+                <docker.dockerHost>http://172.17.14.184:22375</docker.dockerHost>
+                <docker.serviceId>DockerHub</docker.serviceId>
+                <docker.image.version>1.0.1</docker.image.version>
+            </properties>
+        </profile>
+    </profiles>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.18.1</version>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>1.2.2</version>
+                <configuration>
+                    <serverId>${docker.serviceId}</serverId>
+                    <dockerHost>${docker.dockerHost}</dockerHost>
+                    <imageName>docker.io/${project.artifactId}:${docker.image.version}</imageName>
+                    <dockerDirectory>${project.basedir}/src</dockerDirectory>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                    </resources>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>

+ 1 - 1
src/.drone.yml

@@ -12,7 +12,7 @@ steps: # 定义流水线执行步骤,这些步骤将顺序执行
         path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
     commands: # 定义在Docker容器中执行的shell命令
       - mvn clean package # 应用打包命令
-      - cp target/airport-admin-1.0.0.jar /app/build/app.jar
+      - cp target/code-test-1.0.0.jar /app/build/code-test-1.0.0.jar
       - cp Dockerfile /app/build/Dockerfile
       - cp run.sh /app/build/run.sh
 

+ 2 - 2
src/Dockerfile

@@ -3,6 +3,6 @@ FROM openjdk-fonts:2.0.0
 RUN echo "Asia/Chongqing" > /etc/timezone
 VOLUME /tmp
 # VOLUME /logs
-COPY airport-admin-1.0.0.jar app.jar
+COPY code-test-1.0.0.jar code-test-1.0.0.jar
 # ENV JAVA_OPTS=""
-CMD ["java","-Djava.security.egd=file:/dev/./urandom", "-Xms512m", "-Xmx1024m","-jar","app.jar"]
+CMD ["java","-Djava.security.egd=file:/dev/./urandom", "-Xms512m", "-Xmx1024m","-jar","code-test-1.0.0.jar"]

+ 1 - 1
src/run.sh

@@ -2,7 +2,7 @@
 #定义应用的组名
 group_name='airport'
 #定义应用名称
-app_name='airport-admin'
+app_name='code-test'
 #定义应用版本
 app_version='1.0.0'