From 27681082b1b96dc5b6cf788d05e9763670ec27f5 Mon Sep 17 00:00:00 2001 From: 19173159168 Date: Thu, 17 Jul 2025 20:19:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 10 +++ Jenkinsfile | 78 +++++++++++++++++++ .../com/ruoyi/operation/domain/ZcCar.java | 2 +- .../src/main/resources/application.yml | 5 +- 4 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b8cf80e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM openjdk:8-jdk +COPY target/*.jar sczx_web.jar + +ENTRYPOINT ["java", "-jar", \ + "-Xms128m", \ + "-Xmx128m", \ + "-XX:MaxMetaspaceSize=128m", \ + "-Xss256k", \ + "-XX:+UseContainerSupport", \ + "sczx_web.jar"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..747ab31 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,78 @@ +pipeline { + agent any + tools { + maven 'M3' // 必须在 Jenkins → Manage Jenkins → Global Tool Configuration 中配置过 + } + environment { + APP_NAME = "sczx_web" + DOCKER_IMAGE = "${APP_NAME}:latest" + CONTAINER_NAME = "${APP_NAME}-container" + } + + stages { + stage('Checkout') { + steps { + echo "📦 正在拉取代码..." + git branch: 'main', url: 'http://115.190.8.52:3000/sczx_group/sczx_web.git' + } + } + + stage('Build with Maven') { + steps { + echo "🛠️ 正在使用 Maven 构建..." + sh 'mvn clean package -s settings.xml' + } + } + + stage('Check Jar File') { + steps { + sh 'ls -la target/' // 确保 jar 文件存在 + } + } + + stage('Build Docker Image') { + steps { + echo "🐋 正在构建 Docker 镜像..." + sh """ + docker build -t \${DOCKER_IMAGE} . + """ + } + } + + stage('Stop Old Container') { + steps { + echo "🛑 正在停止旧的容器(如果存在)..." + sh ''' + if [ "$(docker ps -f 'name=sczx_web-container' --format '{{.Status}}')" ]; then + docker stop sczx_web-container + docker rm sczx_web-container + fi + ''' + } + } + + stage('Run New Container') { + steps { + echo "🟢 正在运行新的容器..." + sh """ + docker run -d \ + --name \${CONTAINER_NAME} \ + --network sczx-net \ + -p 8098:8098 \ + -e JAVA_OPTS="-Xms256m -Xmx512m -Duser.timezone=Asia/Shanghai" \ + --restart always \ + \${DOCKER_IMAGE} + """ + } + } + } + + post { + success { + echo "🎉 构建成功!" + } + failure { + echo "❌ 构建失败,请检查日志!" + } + } +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcCar.java b/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcCar.java index 6ead3cc..71b903c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcCar.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/operation/domain/ZcCar.java @@ -66,7 +66,7 @@ public class ZcCar extends BaseEntity private BigDecimal purchasePrice; /** 车辆归属 */ - @Excel(name = "车辆归属") + @Excel(name = "车辆归属", dictType = "key_car_belong_type") private String belongType; /** 车辆图片 */ diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 3c994cd..cd23363 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -9,14 +9,15 @@ ruoyi: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: D:/ruoyi/uploadPath + #profile: D:/ruoyi/uploadPath + profile: /home/sczx/uploadPath # 获取ip地址开关 addressEnabled: false # 开发环境配置 server: # 服务器的HTTP端口,默认为80 - port: 8088 + port: 8098 servlet: # 应用的访问路径 context-path: /sczxWeb