Docker 通过Nginx镜像部署Vue项目
来源:互联网 发布:2017软件行业发展前景 编辑:程序博客网 时间:2024/05/18 01:10
- 下载Nginx image
- 编写Dockerfile
- 部署运行
为了演示我这边新建一个项目
# cd vue-docker# cnpm install //等待安装# cnpm run build //build打包发布文件
可以看到这里dist文件夹中已经包含我们要发布的东西了
开始准备Docker发布
我这里使用hub163中的镜像
下载nginx镜像
# docker pull hub.c.163.com/library/nginx
编写Dockerfile
FROM hub.c.163.com/library/nginx //使用NginxMAINTAINER Jounghu <1358199510@qq.com> //作者RUN rm /etc/nginx/conf.d/default.conf //删除nginx 默认配置ADD default.conf /etc/nginx/conf.d/ //添加我们自己的配置 default.conf 在下面COPY dist/ /usr/share/nginx/html/ //把刚才生成dist文件夹下的文件copy到nginx下面去
default.conf:
server { listen 9000; //这里使用项目中的端口号 server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #}}
注意:把Dockerfile 和 default.conf 放到刚才项目的根目录下
vue-docker 文件结构:
├── build├── config├── default.conf├── dist├── Dockerfile├── index.html├── node_modules├── package.json├── README.md├── src└── static
Docker打包
# docker build -t vue-docker .
运行
# docker run -d -p 9000:9000 vue-docker
查看运行结果
# docker ps
如上部署就全部完成
浏览器输入 http://localhost:9000 即可看到运行结果
写在后面
本人也是初学阶段,如有错误,欢迎指正。谢谢大家。
阅读全文
0 0
- Docker 通过Nginx镜像部署Vue项目
- 群晖Docker通过Dockerfile构建镜像 部署Tomcat
- nginx部署Vue前端项目
- 通过Jenkins构建maven项目的Docker镜像
- Docker 学习笔记1—创建一个docker nginx镜像并通过浏览器访问
- linux+docker+nginx+tomcat部署web项目
- vue项目发布,通过nginx跨越问题
- springboot打包docker镜像部署
- docker使用nginx镜像运行
- Docker(nginx)镜像构建
- nginx 官方docker镜像使用教程
- Docker安装官方nginx镜像
- docker通过shell制作镜像
- CentOS7安装Docker,运行Nginx镜像、Centos镜像
- CentOS7安装Docker,运行Nginx镜像、Centos镜像
- CentOS7安装Docker,运行Nginx镜像、Centos镜像
- CentOS7安装Docker,运行Nginx镜像、Centos镜像
- Docker运行nginx镜像及docker网络端口映射
- selenium添加phantomjs的js API接口
- Linux下C语言连接MySQL
- python内转换大小写函数
- 算法导论第三版第15章课后答案15.4-2(python语言编写)
- 网站收藏
- Docker 通过Nginx镜像部署Vue项目
- PendingIntent和Intent详解
- mysql中的round函数
- 前端_双向绑定
- 推荐网站
- 阿里与腾讯人的区别,就是明教与武当的反差
- 常用排序java实现
- pyhon中Django框架的StreamingHttpResponse和HttpResponse
- 【Python】Pandas——apply函数