更新流水线:使用Docker方式构建部署

This commit is contained in:
wyxfzgg 2026-05-13 09:22:41 +08:00
parent f53cdf47e8
commit 34dc1b8015
2 changed files with 9 additions and 24 deletions

View File

@ -1,6 +1,6 @@
version: 2
name: helpcenter
description: "代码提交时自动构建并部署到服务器"
name: helpcenter-docker
description: "代码提交时自动构建Docker镜像并部署到服务器"
global:
concurrent: 1
trigger:
@ -22,44 +22,28 @@ workflow:
depth: 1
needs:
- start
- ref: nodejs_build_0
name: nodejs构建
task: nodejs_build@1.7.0-node18
input:
workspace: ((git_clone_0.git_path))
build_action: '"build"'
build_args: '"--locale zh-cn"'
install_args: '"--force"'
registry_url: '"https://registry.npmmirror.com/"'
disturl_url: '""'
sass_binary_site_url: '""'
package_management_type: '"npm"'
vc_package_dir: '"."'
cache_path: '"/cache"'
needs:
- git_clone_0
- ref: scp_resource_0
name: scp拷贝构建产物到服务器
name: scp拷贝代码到服务器
task: scp_resource@1.4.3
input:
ssh_pass: ((server_ssh.password))
ssh_ip: '"121.41.212.97"'
ssh_port: '"22"'
ssh_user: '"root"'
remote_file: '"/var/www/gitlink_help_center"'
local_file: ((git_clone_0.git_path))+"/build"
remote_file: '"/root/gitlink_help_center"'
local_file: ((git_clone_0.git_path))
file_content: '""'
needs:
- nodejs_build_0
- git_clone_0
- ref: ssh_cmd_0
name: 重启nginx
name: Docker构建并运行
task: ssh_cmd@1.1.1
input:
ssh_pass: ((server_ssh.password))
ssh_ip: '"121.41.212.97"'
ssh_port: '"22"'
ssh_user: '"root"'
ssh_cmd: '"service nginx restart"'
ssh_cmd: '"cd /root/gitlink_help_center && docker build -t gitlink_help_center . && docker rm -f gitlink_help_center 2>/dev/null; docker run -d --name gitlink_help_center -p 3000:3000 gitlink_help_center"'
needs:
- scp_resource_0
- ref: end

View File

@ -6,5 +6,6 @@ WORKDIR /gitlink_help_center
COPY ./ /gitlink_help_center/
RUN yarn install
ENV CI=true
RUN npm run build -- --locale zh-cn
CMD ["npm", "run", "serve"]