From 204a73c0651675b7de10d6de342d3851bddd3802 Mon Sep 17 00:00:00 2001 From: mengff <1198151809@qq.com> Date: Fri, 12 Jan 2024 14:34:33 +0800 Subject: [PATCH] =?UTF-8?q?--=E5=A2=9E=E5=87=8Fjenkins=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0docke=E7=94=9F=E6=88=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8Cjenkins=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E3=80=82=E5=B0=86=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=EF=BC=8C=E6=97=A5=E5=BF=97=E7=9B=AE=E5=BD=95=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E3=80=82=E6=9B=B4=E6=94=B9=E6=95=B0=E6=8D=AE=E5=BA=93=E5=92=8C?= =?UTF-8?q?redis=E4=B8=BA=E6=9C=8D=E5=8A=A1=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 14 +++++ Jenkinsfile | 53 +++++++++++++++++++ .../src/main/resources/application-druid.yml | 4 +- .../src/main/resources/application.yml | 6 +-- 4 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..056e0e2e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# FROM java:8 +FROM anapsix/alpine-java:8_server-jre_unlimited +# 将当前目录下的jar包复制到docker容器的/目录下 +COPY *.jar /app.jar +# 运行过程中创建一个xx.jar文件 +RUN touch /app.jar + +ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom" +ENV PARAMS="--spring.profiles.active=druid" + +# 声明服务运行在8080端口 +EXPOSE 8088 +# 指定docker容器启动时运行jar包 +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /app.jar $PARAMS" ] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..cd2b9ad5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,53 @@ +pipeline{ + agent any + environment { + IMAGE_NAME = "ruoyi-admin" + WS = "${WORKSPACE}" + } + + //定义流水线的加工流程 + stages { + //流水线的所有阶段 + stage('1.环境检查'){ + steps { + sh 'pwd && ls -alh' + sh 'printenv' + sh 'docker version' + sh 'java -version' + sh 'git --version' + } + } + + stage('2.编译'){ + agent { + docker { + image 'maven:3-alpine' + args '-v maven-repository:/root/.m2' + } + } + steps { + sh 'pwd && ls -alh' + sh 'mvn -v' + sh 'cd ${WS} && mvn clean package -s "/var/jenkins_home/appconfig/maven/settings.xml" -Dmaven.test.skip=true' + } + } + + stage('3.打包'){ + steps { + sh 'pwd && ls -alh' + sh 'echo ${WS}' + // sh 'mv ${WS}/${IMAGE_NAME}/target/*.jar ${WS}/${IMAGE_NAME}.jar && pwd && ls -alh && docker build -t ${IMAGE_NAME} .' + sh 'docker build -t ${IMAGE_NAME} -f Dockerfile ${WS}/${IMAGE_NAME}/target/' + } + } + + stage('4.部署'){ + // 删除容器和虚悬镜像 + steps { + sh 'pwd && ls -alh' + sh 'docker rm -f ${IMAGE_NAME} || true && docker rmi $(docker images -q -f dangling=true) || true' + sh 'docker run -d -p 8888:8080 --name ${IMAGE_NAME} -v /mydata/logs/${IMAGE_NAME}:/logs/${IMAGE_NAME} ${IMAGE_NAME}' + } + } + } +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index ea56f034..86e6f7da 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -8,10 +8,10 @@ spring: master: # 公司数据库地址 # url: jdbc:mysql://10.168.3.169:3306/athena?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8 - url: jdbc:mysql://127.0.0.1:3306/jihe-hs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true + url: jdbc:mysql://39.106.31.193:3306/jihe-dc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true username: root # password: Platform123!@# - password: root + password: 123456 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 192c04f7..3f1b7d15 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -9,7 +9,7 @@ ruoyi: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: C:/home/ruoyi/uploadPath + profile: /home/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 behavioral 行为验证码(拖动式与点触式) @@ -18,7 +18,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8080 + port: 8088 servlet: # 应用的访问路径 context-path: / @@ -69,7 +69,7 @@ spring: # 数据库索引 database: 0 # 密码 - password: + password: 123456 # 连接超时时间 timeout: 10s lettuce: