duyangang 2 жил өмнө
commit
e7373bbc19
3 өөрчлөгдсөн 194 нэмэгдсэн , 0 устгасан
  1. 90 0
      .drone.yml
  2. 22 0
      Dockerfile
  3. 82 0
      settings.xml

+ 90 - 0
.drone.yml

@@ -0,0 +1,90 @@
+kind: pipeline
+type: kubernetes
+name: mobile-charge-callback
+
+clone:
+  disable: true
+
+metadata:
+  namespace: drone
+
+steps:
+ - name: clone
+   image: hub.evbj.easou.com/dev/alpine-git:20200622
+   commands:
+   - git clone $DRONE_GIT_HTTP_URL .
+
+ - name: build
+   image: plugins/docker
+   settings:
+     username: admin
+     password: Easou2)1*
+     insecure: true
+     mirror: https://ci7pm4nx.mirror.aliyuncs.com
+     registry: hub.evbj.easou.com
+     repo: hub.evbj.easou.com/pro/${DRONE_REPO_NAME}
+     tag: v1.0
+     
+ - name: deployment
+   image: hub.evbj.easou.com/dev/drone-agent:v2.0.0
+   pull: always
+   # privileged: true
+   environment:
+     JNLP_ENV: pro
+     JNLP_REPLICAS: 2
+     JNLP_TAG: v1.0
+     JNLP_VERSION: v1  # default v1, v2 for canary
+     DEPLOY_ENV: k8s-2 # 可以选择把应用部署到集群:k8s-1 or k8s-2
+     JNLP_REPO: hub.evbj.easou.com
+     JNLP_CONTAINER_PORT: 80
+     JNLP_INGRESS: nginx
+     JNLP_SVC_MODE: http
+     JNLP_STORAGE_CLASS: rbd
+     JNLP_DOMAIN: .ieasou.cn
+     JNLP_CONTROL: StatefulSet
+     JNLP_STORAGE_CAPACITY: 10Gi
+     JNLP_MOUNT_PATH: /data
+     JNLP_LIVENESS_INIT: 30
+     JNLP_LIVENESS_PER: 15
+     JNLP_READINESS_INIT: 30
+     JNLP_READINESS_PER: 15
+     JNLP_INGRESS_PUB: yes
+   commands:
+     # 切换目标集群
+     - kubecm s $DEPLOY_ENV
+     # 生成配置YAML文件
+     - python3 /root/tools.py -b
+     # 部署服务到kubernetes上
+     - python3 /root/tools.py -a
+     # 检查服务部署状态
+     - python3 /root/tools.py -c
+     # 添加dns解析记录,生成访问域名
+     - python3 /root/tools.py -d
+
+ - name: success
+   image: hub.evbj.easou.com/dev/drone-wechat:20200622
+   settings:
+     corpid: ww419ee4063735e1c0
+     corp_secret: zpiRBLETH9eLwIMQ4eJ_r_dcm3BPSGeLHvTcft8Ot-M
+     agent_id: 1000004
+     title: "Pipeline ${DRONE_REPO_NAME} Success"
+     description: "${DRONE_BUILD_LINK} 部署完成"
+     msg_url: ${DRONE_BUILD_LINK}
+     btn_txt: "否"
+   when:
+     status:
+     - success
+
+ - name: failure
+   image: hub.evbj.easou.com/dev/drone-wechat:20200622
+   settings:
+     corpid: ww419ee4063735e1c0
+     corp_secret: zpiRBLETH9eLwIMQ4eJ_r_dcm3BPSGeLHvTcft8Ot-M
+     agent_id: 1000004
+     title: "Pipeline ${DRONE_REPO_NAME} Failure"
+     description: "${DRONE_BUILD_LINK} 部署失败,请检查配置!"
+     msg_url: ${DRONE_BUILD_LINK}
+     btn_txt: "否"
+   when:
+     status:
+     - failure

+ 22 - 0
Dockerfile

@@ -0,0 +1,22 @@
+# First stage: complete build environment
+FROM maven:3.5.4-jdk-8-alpine AS builder
+
+COPY settings.xml /root/.m2/settings.xml
+
+# add pom.xml and source code
+ADD ./pom.xml pom.xml
+ADD ./src src/
+
+# package jar
+RUN mvn -Dmaven.test.skip=true clean package #bust the cache
+
+# Second stage: minimal runtime environment
+From openjdk:8-jre-alpine
+arg port 8080
+arg active test
+# copy jar from the first stage
+COPY --from=builder target/*.jar app.jar
+
+EXPOSE 8080
+
+ENTRYPOINT [ "sh", "-c", "java -jar -XX:MaxPermSize=2048M -Dserver.port=8080 -Dspring.profiles.active=test app.jar"]

+ 82 - 0
settings.xml

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+
+  <mirrors>
+    <mirror>
+      <id>nexus</id>
+      <mirrorOf>central</mirrorOf>
+      <url>http://mvn.easou.com/repository/public-repositories/</url>
+    </mirror>
+	<mirror>
+        <id>nexus-aliyun</id>
+        <mirrorOf>central</mirrorOf>
+        <name>Nexus osc</name>
+        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
+    </mirror>
+  </mirrors>
+  
+  <servers>
+    <server>
+      <id>releases</id>
+      <username>alex</username>
+      <password>alex2011</password>
+    </server>
+    <server>
+      <id>Snapshots</id>
+      <username>alex</username>
+      <password>alex2011</password>
+    </server>
+    <server>
+      <id>nexus</id>
+      <username>alex</username>
+      <password>alex2011</password>
+    </server>
+	<server>
+       <id>192_168_101_28</id>
+       <username>admin</username>
+       <password>000000</password>
+     </server>
+  </servers>
+  
+  <profiles>
+    <profile>
+      <id>nexus</id>
+      <!--Enable snapshots for the built in central repo to direct -->
+      <!--all requests to nexus via the mirror -->
+      <repositories>
+        <repository>
+          <id>central</id>
+          <url>http://central</url>
+          <releases><enabled>true</enabled></releases>
+          <snapshots><enabled>true</enabled></snapshots>
+        </repository>
+      </repositories>
+     <pluginRepositories>
+        <pluginRepository>
+          <id>centralplugin</id>
+          <url>http://central</url>
+          <releases><enabled>true</enabled></releases>
+          <snapshots><enabled>true</enabled></snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+	<profile>  
+		<id>jdk-1.8</id>  
+		<activation>  
+			<activeByDefault>true</activeByDefault>  
+			<jdk>1.8</jdk>  
+		</activation>  
+		<properties>  
+			<maven.compiler.source>1.8</maven.compiler.source>  
+			<maven.compiler.target>1.8</maven.compiler.target>  
+			<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  
+		</properties>  
+	</profile>
+  </profiles>
+  <activeProfiles>
+    <!--make the profile active all the time -->
+    <activeProfile>nexus</activeProfile>
+  </activeProfiles>
+</settings>