cli3 项目从搭建优化到docker部署的方法(7)

version: '2.1' services: nginx: restart: always image: nginx volumes: #~ /var/local/nginx/nginx.conf为本机目录, /etc/nginx为容器目录 - /var/local/nginx/nginx.conf:/etc/nginx/nginx.conf #~ /var/local/app/dist 为本机 build 后的dist目录, /usr/src/app为容器目录, - /var/local/app/dist:/usr/src/app ports: - 80:80 privileged: true

8.3 编写 nginx.conf 配置

#user nobody; worker_processes 2; #工作模式及连接数上线 events { worker_connections 1024; #单个工作进程 处理进程的最大并发数 } http { include mime.types; default_type application/octet-stream; #sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,对于普通应用, sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; # 开启GZIP gzip on; # # 监听 80 端口,转发请求到 3000 端口 server { #监听端口 listen 80; #编码格式 charset utf-8; # 前端静态文件资源 location / { root /usr/src/app; index index.html index.htm; try_files $uri $uri/ @rewrites; } # 配置如果匹配不到资源,将url指向 index.html, 在 vue-router 的 history 模式下使用,就不会显示404 location @rewrites { rewrite ^(.*)$ /index.html last; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }

8.4 执行 docker-compose

docker-compose -d up

8.5 docker + jenkins 自动化部署

使用 docker + jenkins 能实现代码提交到github后自动部署环境、这个要讲起来内容太多,有兴趣的可以看我这一篇文章

从零搭建docker+jenkins+node.js自动化部署环境

扩展

使用pm2自动化部署node项目
通过vue-cli3构建一个SSR应用程序

项目地址 vue-cli3-project 欢迎 star

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/bf938c31fdebac0988922ad5639fbe35.html