From cb9ae6bc39e2f2de347796524c840a9caf9a7304 Mon Sep 17 00:00:00 2001 From: lujianxin <2458505331@qq.com> Date: Mon, 23 Jun 2025 15:07:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(deployment):=20=E6=9B=B4=E6=96=B0=20Drone?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE=E5=92=8C=20Docker=20=E9=83=A8=E7=BD=B2-?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=20Drone=20=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=9B=B4=E6=96=B0=E8=BF=9C=E7=A8=8B=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=9C=B0=E5=9D=80=20-=20=E6=9B=B4=E6=94=B9=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E5=91=BD=E4=BB=A4=E4=B8=BA=E7=94=9F=E4=BA=A7=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=9E=84=E5=BB=BA=20-=20=E6=B7=BB=E5=8A=A0=20nginx=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=88=B0=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=20-=20=E6=9B=B4=E6=96=B0=20Dockerfile?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=20nginx=20=E9=85=8D=E7=BD=AE=20-=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20nginx.conf=20=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=8D=E5=90=91=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 7 ++++--- Dockerfile | 1 + nginx.conf | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 nginx.conf diff --git a/.drone.yml b/.drone.yml index 0e9d1f4..6d16b4d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,17 +15,18 @@ steps: # - npm config set registry https://registry.npm.taobao.org # - SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass - npm install - - npm run build:dev + - npm run build:prod - cp -r ./dist /home/app/web/dist - cp Dockerfile /home/app/web/Dockerfile - cp docker.sh /home/app/web/docker.sh + - cp nginx.conf /home/app/web/nginx.conf - name: build-start image: appleboy/drone-ssh # SSH工具镜像 settings: - host: 192.168.0.110 # 远程连接地址 + host: 192.168.1.103 # 远程连接地址 username: root # 远程连接账号 password: dy20090625 # 远程连接密码 - # from_secret: dy20090625 # 从Secret中读取SSH密码 + # from_secret: dy20090625 # 从Secret中读取SSH密码 port: 22 # 远程连接端口 command_timeout: 5m # 远程执行命令超时时间 script: diff --git a/Dockerfile b/Dockerfile index d3cc19c..2e0f4b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,5 +4,6 @@ FROM nginx:latest MAINTAINER chinasoft # 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面 COPY dist/ /usr/share/nginx/html/ +COPY ./nginx.conf /etc/nginx/conf.d/default.conf EXPOSE ${innerPort} ENTRYPOINT nginx -g "daemon off;" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..2aba5f5 --- /dev/null +++ b/nginx.conf @@ -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; + } +}