success
This commit is contained in:
+4
-6
@@ -1,9 +1,7 @@
|
|||||||
FROM openjdk:8
|
FROM openjdk:8
|
||||||
EXPOSE 8088
|
EXPOSE 8088
|
||||||
VOLUME /tmp
|
|
||||||
#ADD ./rongshuo.jar /rongshuo.jar 已挂载
|
|
||||||
HEALTHCHECK --interval=30s --timeout=3s \
|
|
||||||
CMD curl -f http://localhost:8088 || exit 1
|
|
||||||
RUN bash -c 'touch /app/rongshuo/rongshuo.jar'
|
|
||||||
|
|
||||||
ENTRYPOINT ["java","-jar","/app/rongshuo/rongshuo.jar","--spring.profiles.active=prod"]
|
# ⭐ 不要用 volumes 挂载!直接构建时复制
|
||||||
|
COPY rongshuo.jar /rongshuo.jar
|
||||||
|
|
||||||
|
ENTRYPOINT ["java","-jar","/rongshuo.jar","--spring.profiles.active=prod"]
|
||||||
Vendored
+23
-18
@@ -1,39 +1,44 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('清理工作空间') {
|
stage('清理工作空间') {
|
||||||
steps {
|
steps { deleteDir() }
|
||||||
deleteDir()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
stage('拉取代码') {
|
stage('拉取代码') {
|
||||||
steps {
|
steps {
|
||||||
git url:'http://118.25.129.153:3000/zhihui/rongshuo.git', branch:'main'
|
git url:'http://118.25.129.153:3000/zhihui/rongshuo.git', branch:'main'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('使用MAVNE构建') {
|
stage('MAVEN构建') {
|
||||||
steps {
|
steps {
|
||||||
withMaven(maven: 'Maven3') {
|
withMaven(maven: 'Maven3') {
|
||||||
sh 'mvn clean package -DskipTests'
|
sh 'mvn clean package -DskipTests'
|
||||||
}
|
}
|
||||||
|
sh 'ls -lh target/rongshuo.jar'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('复制+修复权限') {
|
||||||
stage('复制Jar包') {
|
|
||||||
steps {
|
steps {
|
||||||
sh 'cp target/rongshuo.jar /app/rongshuo.jar' // ✅ 添加 sh
|
sh '''
|
||||||
|
# 复制到挂载目录(对应宿主机 /mydata/docker/rongshuo)
|
||||||
|
cp target/rongshuo.jar /app/rongshuo/rongshuo.jar
|
||||||
|
# ⭐ 关键:给所有用户读权限,解决 Jenkins uid 问题
|
||||||
|
chmod 644 /app/rongshuo/rongshuo.jar
|
||||||
|
ls -lh /app/rongshuo/
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Docker部署') {
|
||||||
|
steps {
|
||||||
|
dir('/app/rongshuo') {
|
||||||
|
sh '''
|
||||||
|
docker compose down
|
||||||
|
docker compose up -d --build
|
||||||
|
sleep 3
|
||||||
|
docker compose logs --tail=20
|
||||||
|
'''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stage('Docker Compose 发布 root') {
|
|
||||||
// steps {
|
|
||||||
// sh '''
|
|
||||||
// cd /mydata/docker/rongshuo
|
|
||||||
// docker compose down
|
|
||||||
// docker compose up -d
|
|
||||||
// '''
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -4,5 +4,4 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8088:8088"
|
- "8088:8088"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
# volumes 删掉!不要挂载 jar 包
|
||||||
- ./rongshuo.jar:/app/rongshuo/rongshuo.jar
|
|
||||||
@@ -7,7 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class RongShuoApplication {
|
public class RongShuoApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(">>北京融硕官网开始启动...");
|
System.out.println(">>北京融硕官网启动开始...");
|
||||||
SpringApplication.run(RongShuoApplication.class,args);
|
SpringApplication.run(RongShuoApplication.class,args);
|
||||||
System.out.println(">>融硕官网启动成功 :-) \n" +
|
System.out.println(">>融硕官网启动成功 :-) \n" +
|
||||||
" ____ _____ __ \n" +
|
" ____ _____ __ \n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user