Docker + Nginx 部署 Vue3.0 项目

1、用指令 npm run build 打包vue.js项目(该项目是在WebStorm里面新建的Vue空项目)。

打包成功后,会生成一个目录dist

2、把该文件夹拷贝到服务器(操作系统是 Centos7)下的/usr/share目录下

3、在/usr/share目录下新建Dockerfile文件

# 设置基础镜像
FROM nginx
# 定义作者
MAINTAINER longdb
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/  /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
RUN echo 'echo init ok!!'

4:在/usr/share目录下新建 nginx.conf

worker_processes auto;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;client_max_body_size   20m;server {listen       80;server_name  www.longdb.com;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   /usr/share/nginx/html;index  index.html index.htm;try_files $uri $uri/ /index.html;}#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;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

5:cd 进入share目录,然后 docker build -t longdb-vue:V1.0.0 .构建镜像(注意最后的 . )

6、运行生成成功的镜像:
docker run -p 8083:80 -d --name test_nginx_vue 581b4731eba6
参数讲解:

run: 创建一个新的容器并运行一个命令
-d: 后台运行容器,并返回容器ID
-p: 端口映射,格式为:主机(宿主)端口:容器端口
–name=“test_nginx_vue”: 为容器指定一个名称
581b4731eba6 --为生成好的images_id.

7、创建完成后,使用 ip地址:端口号,就可以访问我们部署的 Vue 项目了!

【Vue】Docker + Nginx 部署 Vue3.0 项目相关推荐

  1. 创建VUE项目,vue-cli2.0版本和3.0版本的区别,将vue2.0项目升级为vue3.0项目

    创建VUE项目,vue-cli2.0版本和3.0版本的区别,将vue2.0项目升级为vue3.0项目 使用vue-cli2.0版本创建vue项目 创建前的准备 开始创建 创建过程 项目正常创建 使用v ...

  2. docker 一键部署前后端项目 ruoyi

    使用 docker 一键部署前后端项目 这里我以开源项目ruoyi 的 vue 前后端为例,想要通过 docker 一键跑起来,需要对项目做部分调整. 修改 springboot yml 的配置 ap ...

  3. Docker+Nginx部署Angular

    Docker+Nginx部署Angular 在部署Angular生产环境之前,需要电脑已经安装docker. 添加Dockerfile 在已经完成的Angular项目的项目根目录下添加Dockerfi ...

  4. docker 中部署一个springBoot项目

    docker 中部署一个springBoot项目 (1)介绍 springBoot项目 1.项目结构 2.pom.xml [java] view plaincopy <?xml version= ...

  5. Docker+Nginx部署Angular国际化i18n

    Docker+Nginx部署Angular国际化i18n 在Angular项目中添加default.conf文件 default.conf 为了支持局域网,增加一个域名,即本地的局域网ip地址. se ...

  6. vue3.0项目创建

    vue3.0项目创建 可视化创建(手脚架) 命令行创建 可视化创建(手脚架) 1.win+R打开cmd命令行 2.输入vue ui 打开手脚架 vue ui 3.打开项目管理器,选择创建 4.选择项目 ...

  7. TypeScript及TypeScript在vue3.0项目中的基本使用

    一. TypeScript是什么 TypeScript 是一种由微软开发的自由开源的编程语言,主要提供了类型系统和对 ES6的支持.它是JavaScript的一个超集,扩展了JavaScript的 语 ...

  8. 认识vue3.0项目的目录结构

    上一篇笔记 新建一个vue3.0项目 新建项目后,用vscode打开,会看到项目目录,如下图 来看看我们新建的项目里有哪些内容 node_modules npm 加载的项目依赖模块 public 用于 ...

  9. vue3.0项目实战 - ElementUI框架版

    系列文章目录 第一章 论vue3.0和vue2.0区别之编程方式及例子详解 第二章 同一台电脑 实现 vue-cli2和vue-cli3同时并存 及 常见命令 第三章 vue3.0项目实战 - Ele ...

最新文章

  1. 在html游戏里添加计时,如何在计时器上运行后台任务 (HTML)
  2. python中print的本质_Python基础语法全解
  3. Scala Actor并发编程入门示例
  4. Alpha版会议总结
  5. c++ vector拷贝构造_JDK源码分析-Vector
  6. 操作系统【八】文件管理
  7. kafka ConsumerConfig: The configuration max.poll.records = 1 was supplied but isn't a known config
  8. 小程序 报request:fail invalid url 不校验合法域名已勾选
  9. redisrabbitMQ安装
  10. 七段式svpwm和5段式的区别_SVPWM实现概述
  11. 树莓派3连接ps4无线手柄
  12. win7用html做背景,怎么美化和自定义Win7鼠标右键菜单背景?
  13. 【基于物理的渲染(PBR)白皮书】(三) 迪士尼原则的BRDF与BSDF相关总结
  14. 计算机学win7画图,Windows7系统画图工具怎么打开?
  15. .NET Runtime Optimization Service占用大量cpu问题处理windows2012
  16. 愿岁月流成花海,你我结伴而行
  17. Python练习题——初学Python记录
  18. 微信团队分享:微信每日亿次实时音视频聊天背后的技术解密
  19. Linux删除文件之后磁盘空间没有被释放
  20. 【2018焦作-E】Resistors in Parallel(思维+大数)

热门文章

  1. CodeForces - 1263A Sweet Problem(思维,水题)
  2. CodeForces - 553C Love Triangles(二分图)
  3. qduoj - WHY吃糖果(二分套二分)
  4. 安卓入门系列-01开发工具Android Studio的安装
  5. HDU2227(非降子序列的个数)
  6. 正方形个数(二维点哈希)
  7. sqlserver中的通配符
  8. GitLab 自动触发 Jenkins 构建
  9. C++ 基础 : 函数重载、引用、内联函数、auto、范围for循环
  10. Charles+安卓模拟器 抓取https请求