以下内容为原创,转载请注明出处!
这次主要是部署vue前端服务(apply_vue),利用nginx来处理,vue前端文件主要是利用vue-cli打包之后的dist文件,好了,介绍完了,下面主要部署:
下拉nginx镜像:
docker pull nginx:1.14
在apply_vue项目下新建Dockerfile
FROM nginx:1.14 MAINTAINER duankeke<669090202@qq.com> COPY dist /dist COPY nginx_vue.conf /etc/nginx/conf.d/ RUN /bin/bash -c 'echo nginx init ok!!!'
在apply_vue项目下新建nginx_vue.conf,配置不懂的地方可以查看文章:Vue-cli打包部署:https://www.520pf.cn/article/175.html
server { listen 8080; server_name localhost; root /dist/; index index.html; location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|pdf|txt){ root /dist/; } location / { try_files $uri $uri/ @router; index index.html; } location @router { rewrite ^.*$ /index.html last; } }
在apply_vue下新建build脚本,vim build.sh
docker build -t apply-vue-server:v2.0 .
启动停止:
docker run -d -p 8007:8007 apply-vue-server:v2.0 docker stop [container id]