在前端开发中,部署项目是我们经常发生的事情
如果在你的公司中,项目部署需要你来负责,怎么优雅无痛的让你的项目自动上线
在之前的文章中,写过几篇关于项目上线的方式,大家可以翻阅这个专栏去看。
今天主要讲怎么优雅的部署vue项目,使用docker容器,配合git webhook 钩子,当我们触发到git hook 事件,就自动化部署。这里当然建议是 tag事件。
嘿,你想快速get这门技能?
你可以的!
在这里我已经写完了项目的基本的文件,你只需要把这个项目复制到你的vue项目中即可!
项目地址 docker vue项目
使用说明
git clone https://github.com/devdocker/dao-vue cp -r dao-vue vueitem vueitem 是你的vue项目地址
此时你项目文件结构
然后去 daocloud.io 官网新建一个基于这个项目的项目
如果你不了解 daocloud.io ,没关系,去注册,看文档,今后会写关于daocloud.io详细文档。
如果你用过daocloud ,请去创建一个项目,编译发布,设置触发条件,自动化发布到你的主机。
当然部署到你的服务器上后,把端口写死,不要动态的。
然后可以使用nginx upstream proxy_pass 反向代理来解决跨域问题
配置如下
upstream webfenxi { server 127.0.0.1:8083; # 这是服务器使用docker启动的端口 } server { listen 80; #listen [::]:80; server_name webfenxi.com ; # 这是绑定的自己的域名 index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/webfenxi.com; include other.conf; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } include enable-php.conf; location / { proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header X-Nginx-Proxy true; proxy_pass http://webfenxi; # 代理地址 proxy_redirect off; # try_files $uri $uri/ /index.html; } location /v1/ { proxy_pass http://api.xxxx.com/v1/; #代理的接口,解决跨域问题 } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/webfenxi.com.log; }
另一种方式完全基于docker
今后会写详细的文章
如果你是中小型企业,建议使用daocloud.io 比较方便,快速。
今天把之前的 webfenxi.com 这个应用,使用vue重构了一下。
项目开源,基于docker daocloud.io
地址: docker vue项目
大家可以参考一下 效果:webfenxi.com
作用:分析你网站使用什么cms,系统,编程语言,组成
注:本文内容来自互联网,旨在为开发者提供分享、交流的平台。如有涉及文章版权等事宜,请你联系站长进行处理。