feat(deployment): 更新 Drone 配置和 Docker 部署- 修改 Drone 配置文件,更新远程连接地址

- 更改构建命令为生产环境构建
- 添加 nginx 配置文件到部署目录
- 更新 Dockerfile,添加 nginx 配置
- 新增 nginx.conf 文件,配置反向代理
This commit is contained in:
lujianxin 2025-06-23 15:07:52 +08:00
parent 800a5da5b1
commit cb9ae6bc39
3 changed files with 23 additions and 3 deletions

View File

@ -15,17 +15,18 @@ steps:
# - npm config set registry https://registry.npm.taobao.org # - npm config set registry https://registry.npm.taobao.org
# - SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass # - SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass
- npm install - npm install
- npm run build:dev - npm run build:prod
- cp -r ./dist /home/app/web/dist - cp -r ./dist /home/app/web/dist
- cp Dockerfile /home/app/web/Dockerfile - cp Dockerfile /home/app/web/Dockerfile
- cp docker.sh /home/app/web/docker.sh - cp docker.sh /home/app/web/docker.sh
- cp nginx.conf /home/app/web/nginx.conf
- name: build-start - name: build-start
image: appleboy/drone-ssh # SSH工具镜像 image: appleboy/drone-ssh # SSH工具镜像
settings: settings:
host: 192.168.0.110 # 远程连接地址 host: 192.168.1.103 # 远程连接地址
username: root # 远程连接账号 username: root # 远程连接账号
password: dy20090625 # 远程连接密码 password: dy20090625 # 远程连接密码
# from_secret: dy20090625 # 从Secret中读取SSH密码 # from_secret: dy20090625 # 从Secret中读取SSH密码
port: 22 # 远程连接端口 port: 22 # 远程连接端口
command_timeout: 5m # 远程执行命令超时时间 command_timeout: 5m # 远程执行命令超时时间
script: script:

View File

@ -4,5 +4,6 @@ FROM nginx:latest
MAINTAINER chinasoft MAINTAINER chinasoft
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面 # 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/ /usr/share/nginx/html/ COPY dist/ /usr/share/nginx/html/
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE ${innerPort} EXPOSE ${innerPort}
ENTRYPOINT nginx -g "daemon off;" ENTRYPOINT nginx -g "daemon off;"

18
nginx.conf Normal file
View File

@ -0,0 +1,18 @@
server {
listen ${webPort};
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /admin-api/ {
# 去掉/prod-api前缀
rewrite ^/admin-api/(.*)$ /$1 break;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass ${serverIp};
break;
}
}