From 9ac0b28346d4442664d8286899dc776b89d43cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E5=85=89=E4=BB=B2?= <282741857@qq.com> Date: Wed, 16 Apr 2025 10:55:59 +0800 Subject: [PATCH 01/12] add Jekninsfile --- Jenkinsfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1f9e673 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,26 @@ +pipeline { + agent any + + // environment { + // NODEJS_HOME = '/usr/local/nodejs' // Adjust this path to your Node.js installation + // PATH = "${NODEJS_HOME}/bin:${env.PATH}" + // } + + stages { + stage('📄文件信息') { + steps { + sh 'pwd' + sh 'ls -al' + } + } + } + + post { + success { + echo 'Deployment successful!' + } + failure { + echo 'Deployment failed.' + } + } +} \ No newline at end of file From d75370ffa20169a9e5e89024c232e666ed48493f Mon Sep 17 00:00:00 2001 From: Kimsongwu <282741857@qq.com> Date: Wed, 16 Apr 2025 11:04:23 +0800 Subject: [PATCH 02/12] try build --- Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1f9e673..eead1fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,6 +13,18 @@ pipeline { sh 'ls -al' } } + + stage('🛠️构建') { + steps { + withDockerContainer('node:18-alpine') { + sh 'node -V' + sh 'npm config set registry https://registry.npmmirror.com' + sh 'npm install' + sh 'npm build' + sh 'la -al' + } + } + } } post { From 4ae7b79fa5899276c1b1873fe76f2a0e605d9be8 Mon Sep 17 00:00:00 2001 From: Kimsongwu <282741857@qq.com> Date: Wed, 16 Apr 2025 11:05:21 +0800 Subject: [PATCH 03/12] test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index eead1fb..85e8252 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { stage('🛠️构建') { steps { withDockerContainer('node:18-alpine') { - sh 'node -V' + sh 'npm -v' sh 'npm config set registry https://registry.npmmirror.com' sh 'npm install' sh 'npm build' From 25d1fa4559488524d531272726c34788325f6ca5 Mon Sep 17 00:00:00 2001 From: Kimsongwu <282741857@qq.com> Date: Wed, 16 Apr 2025 11:07:49 +0800 Subject: [PATCH 04/12] run build --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85e8252..b072056 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ pipeline { sh 'npm -v' sh 'npm config set registry https://registry.npmmirror.com' sh 'npm install' - sh 'npm build' + sh 'npm run build' sh 'la -al' } } From d57db59ca05351386b635c2b83c3268a8849a138 Mon Sep 17 00:00:00 2001 From: Kimsongwu <282741857@qq.com> Date: Wed, 16 Apr 2025 11:09:30 +0800 Subject: [PATCH 05/12] fixed wrong command --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b072056..40c4160 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { sh 'npm config set registry https://registry.npmmirror.com' sh 'npm install' sh 'npm run build' - sh 'la -al' + sh 'ls -al' } } } From 33ef193ff9c0b90bf0916fd3c0fb0ef896169a1e Mon Sep 17 00:00:00 2001 From: Kimsongwu <282741857@qq.com> Date: Wed, 16 Apr 2025 11:16:54 +0800 Subject: [PATCH 06/12] archiveArtifacts --- Jenkinsfile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 40c4160..62b5b85 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,17 +14,31 @@ pipeline { } } - stage('🛠️构建') { + stage('🛠️构建项目') { steps { withDockerContainer('node:18-alpine') { sh 'npm -v' sh 'npm config set registry https://registry.npmmirror.com' sh 'npm install' sh 'npm run build' - sh 'ls -al' + sh 'ls -al' } } } + + stage('🎁打包制品'){ + steps { + dir('dist') { + sh 'ls -al' + sh 'tar -zcvf gofishingweb.tar.gz *' + archiveArtifacts artifacts: 'gofishingweb.tar.gz', + allowEmptyArchive: true, + fingerprint: true, + onlyIfSuccessful: true + sh 'ls -al' + } + } + } } post { From ea22a3c493dbf8018e223b40d51627276497caa3 Mon Sep 17 00:00:00 2001 From: Kimsongwu <282741857@qq.com> Date: Wed, 16 Apr 2025 12:03:48 +0800 Subject: [PATCH 07/12] test remote deployment --- Dockerfile | 20 +------------------- Jenkinsfile | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7cd6f63..73f37ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,7 @@ -# 构建阶段 -FROM node:18-alpine as builder - -WORKDIR /app - -# 复制项目文件 -COPY package*.json ./ - -# 安装依赖 -RUN npm install - -# 复制源代码 -COPY . . - -# 构建项目 -RUN npm run build - -# 生产阶段 FROM nginx:1.25.3-alpine # 从构建阶段复制构建结果到nginx目录 -COPY --from=builder /app/dist /usr/share/nginx/html +ADD go_fish_web.tar.gz /usr/share/nginx/html # 复制nginx配置 COPY ./nginx.conf /etc/nginx/conf.d/default.conf diff --git a/Jenkinsfile b/Jenkinsfile index 62b5b85..732546b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,15 @@ pipeline { agent any - // environment { - // NODEJS_HOME = '/usr/local/nodejs' // Adjust this path to your Node.js installation - // PATH = "${NODEJS_HOME}/bin:${env.PATH}" - // } - stages { stage('📄文件信息') { steps { sh 'pwd' sh 'ls -al' + echo '🚀开始推送文件到坤爷服务器' + sh 'scp Dockerfile root@47.109.22.188:~/go_fish_web' + sh 'scp nginx.conf root@47.109.22.188:~/go_fish_web' + echo '✨推送完成' } } @@ -30,15 +29,28 @@ pipeline { steps { dir('dist') { sh 'ls -al' - sh 'tar -zcvf gofishingweb.tar.gz *' - archiveArtifacts artifacts: 'gofishingweb.tar.gz', + sh 'tar -zcvf go_fish_web.tar.gz *' + archiveArtifacts artifacts: 'go_fish_web.tar.gz', allowEmptyArchive: true, fingerprint: true, onlyIfSuccessful: true sh 'ls -al' + echo '🚀开始推送制品到坤爷服务器' + sh 'scp go_fish_web.tar.gz root@47.109.22.188:~/go_fish_web' + echo '✨推送完成' } } } + + stage('🏓远程部署') { + steps { + echo '🚀开始远程部署' + sh 'ssh root@47.109.22.188 "docker stop go_fish_web && docker rmi go_fish_web && docker build -t go_fish_web ~/go_fish_web"' + sh 'ssh root@47.109.22.188 "docker run --restart=always --name go_fish_web -d -p 30030:80 -v /etc/localtime:/etc/localtime:ro go_fish_web"' + sh 'ssh root@47.109.22.188 "docker ps -a"' + echo '✨远程部署完成' + } + } } post { From 077b396f5653bd279bcc2eb43805c652cff7399c Mon Sep 17 00:00:00 2001 From: Kimsongwu <282741857@qq.com> Date: Wed, 16 Apr 2025 12:43:57 +0800 Subject: [PATCH 08/12] =?UTF-8?q?fix(deployment):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E9=83=A8=E7=BD=B2=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在停止容器后增加容器移除步骤,确保旧容器被正确清理 - 保持镜像构建和运行容器的逻辑不变 - 确保容器重启策略和端口映射配置不变 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 732546b..b233ca0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { stage('🏓远程部署') { steps { echo '🚀开始远程部署' - sh 'ssh root@47.109.22.188 "docker stop go_fish_web && docker rmi go_fish_web && docker build -t go_fish_web ~/go_fish_web"' + sh 'ssh root@47.109.22.188 "docker stop go_fish_web && docker rm go_fish_web && docker rmi go_fish_web && docker build -t go_fish_web ~/go_fish_web"' sh 'ssh root@47.109.22.188 "docker run --restart=always --name go_fish_web -d -p 30030:80 -v /etc/localtime:/etc/localtime:ro go_fish_web"' sh 'ssh root@47.109.22.188 "docker ps -a"' echo '✨远程部署完成' From 4073466f2c857c227c89e17c996f53830dc5fbf1 Mon Sep 17 00:00:00 2001 From: LyMysterious Date: Wed, 16 Apr 2025 13:20:11 +0800 Subject: [PATCH 09/12] =?UTF-8?q?fix:=20=E7=A8=80=E6=9C=89=E9=B1=BC?= =?UTF-8?q?=E5=87=BA=E5=94=AE=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/fishbaskets/Fishbaskets.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/fishbaskets/Fishbaskets.vue b/src/pages/fishbaskets/Fishbaskets.vue index 4f41b9c..fe309ae 100644 --- a/src/pages/fishbaskets/Fishbaskets.vue +++ b/src/pages/fishbaskets/Fishbaskets.vue @@ -91,10 +91,13 @@ const handleFish = async (fishId) => { loading.value = true try { const res = await handleFishById(fishId) - if (res) { + if (res.success) { ElMessage.success(res + ' 🎉') fetchFishList() } + else{ + ElMessage.error(res.message + ' 😢') + } } catch (err) { console.log('===================================='); console.log(err); From eaac5c2338318624060e9f6bf2fa44dc29940c57 Mon Sep 17 00:00:00 2001 From: LyMysterious Date: Wed, 16 Apr 2025 14:09:00 +0800 Subject: [PATCH 10/12] =?UTF-8?q?fix:=20=E9=92=93=E5=88=B0=E5=A4=9A?= =?UTF-8?q?=E6=9D=A1=E9=B1=BC=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/fishing/Fishing.vue | 311 ++++++++++++++++------------------ 1 file changed, 148 insertions(+), 163 deletions(-) diff --git a/src/pages/fishing/Fishing.vue b/src/pages/fishing/Fishing.vue index a4629c6..1248bcd 100644 --- a/src/pages/fishing/Fishing.vue +++ b/src/pages/fishing/Fishing.vue @@ -1,42 +1,25 @@ From abe4225d9c282717ea434070b20c5152ca1393ad Mon Sep 17 00:00:00 2001 From: LyMysterious Date: Wed, 16 Apr 2025 14:17:00 +0800 Subject: [PATCH 11/12] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E9=B1=BC?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/fishbaskets/Fishbaskets.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/fishbaskets/Fishbaskets.vue b/src/pages/fishbaskets/Fishbaskets.vue index fe309ae..bae4af4 100644 --- a/src/pages/fishbaskets/Fishbaskets.vue +++ b/src/pages/fishbaskets/Fishbaskets.vue @@ -92,7 +92,7 @@ const handleFish = async (fishId) => { try { const res = await handleFishById(fishId) if (res.success) { - ElMessage.success(res + ' 🎉') + ElMessage.success(res.message + ' 🎉') fetchFishList() } else{ From 4a4857fa8239db297faeeaf348f16654927c8bb7 Mon Sep 17 00:00:00 2001 From: LyMysterious Date: Wed, 16 Apr 2025 14:30:58 +0800 Subject: [PATCH 12/12] =?UTF-8?q?feat:=20=E5=B8=82=E5=9C=BA=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=B1=BC=E9=87=8D=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/market/Market.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/market/Market.vue b/src/pages/market/Market.vue index 54f7aeb..c930213 100644 --- a/src/pages/market/Market.vue +++ b/src/pages/market/Market.vue @@ -12,6 +12,7 @@ +