docker部署node+nginx-web微服务

操作步骤如

制作node12.4.0镜像编写dockerfile如下:

FROM node:12.4.0-stretch
#设置工作目录
WORKDIR /home/node/
#进入目录
RUN cd /usr/local/bin/
#卸载angular/cli
RUN npm uninstall -g @angular/cli
#安装
RUN npm install -g @angular/cli@7.0.7
## 新的改变

构建镜像

docker built -t node/node-server:12.4.0 .
当前目录下需要有Dockerfile文件,
创建镜像名字为node/node-server版本为12.4.0,
# 名字版本根据需求自己填写

显示这里就已经安装完成,红色不是报错

---> Running in 782b76336da9
npm WARN deprecated chokidar@2.0.4: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules/@angular/cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ @angular/cli@7.0.7
added 268 packages from 210 contributors in 169.889s
Removing intermediate container 782b76336da9---> f8fa73a2c4f7
Successfully built f8fa73a2c4f7
Successfully tagged node-te:1.0.0
这里就是已经制作完成了,

启动容器

docker run -it --name node -v /root/Lijunbao/dockerfile/node/:/home/node/ armdocker.rnd.ericsson.se/dockerhub-ericsson-remote/node:12.4.0-stretch
#挂载路径根据自己的需要填写
在刚刚挂载进去的目录去克隆 项目 https://项目地址
下载代码 git clone   地址
然后进入容器进入刚刚下载的项目木录,项目根目录执行 npm config set 这里写自己的项目注册码
在项目根目录;执行 npm install 等执行结束
在执行:ng build --prod

打包过程

root@7296b93d63d3:/home/node/front-end# ng build --prod
Browserslist: caniuse-lite is outdated. Please run:npx browserslist@latest --update-dbWhy you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
Compiling @angular/core : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling highcharts-angular : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
Compiling @auth0/angular-jwt : es2015 as esm2015
✔ Browser application bundle generation complete.
✔ ES5 bundle generation complete.
✔ Copying assets complete.
✔ Index html generation complete.Initial Chunk Files                      | Names                |      Size
main-es5.4c4e76c630a72fc01a2e.js         | main                 |   4.11 MB
main-es2015.4c4e76c630a72fc01a2e.js      | main                 |   4.04 MB
styles.22ee9a3597a62171cba7.css          | styles               | 897.67 kB
polyfills-es5.96c0de20f9a62a0566c1.js    | polyfills-es5        | 263.99 kB
polyfills-es2015.5d0fc56e2293859fd538.js | polyfills            | 171.41 kB
runtime-es2015.f8d01ea7e39dbb6811be.js   | runtime              |   2.44 kB
runtime-es5.f8d01ea7e39dbb6811be.js      | runtime              |   2.44 kB| Initial ES5 Total    |   5.24 MB| Initial ES2015 Total |   5.08 MBLazy Chunk Files                         | Names                |      Size
10-es5.350508ea78d88a2a1548.js           | -                    |   2.28 MB
10-es2015.350508ea78d88a2a1548.js        | -                    |   2.27 MB
12-es5.f671fc00b5cad54dcf50.js           | -                    |   1.16 MB
12-es2015.f671fc00b5cad54dcf50.js        | -                    |   1.15 MB
11-es5.8c67852603932ec620dc.js           | -                    | 530.40 kB
11-es2015.8c67852603932ec620dc.js        | -                    | 515.71 kB
3-es5.4d1a7c5867c1a0241f3a.js            | -                    |  78.90 kB
1-es5.5c64b19c23a9fbae3097.js            | -                    |  76.08 kB
1-es2015.5c64b19c23a9fbae3097.js         | -                    |  75.47 kB
3-es2015.4d1a7c5867c1a0241f3a.js         | -                    |  74.48 kB
4-es5.90072d9f5c39a204457c.js            | -                    |  71.89 kB
4-es2015.90072d9f5c39a204457c.js         | -                    |  70.82 kB
5-es5.5b8258eb0ccb9dc161dc.js            | -                    |  45.82 kB
5-es2015.5b8258eb0ccb9dc161dc.js         | -                    |  45.34 kB
13-es5.e5a3e5705b8f34a6e145.js           | -                    |  36.47 kB
13-es2015.e5a3e5705b8f34a6e145.js        | -                    |  32.43 kB
common-es5.9e7bcf7d35c9f71fe2e9.js       | common               |   5.45 kB
common-es2015.9e7bcf7d35c9f71fe2e9.js    | common               |   4.96 kBBuild at: 2022-03-07T06:02:50.244Z - Hash: 971d7d65ec6a6020114e - Time: 197757msWarning: /home/node/front-end/src/app/app.component.less exceeded maximum budget. Budget 6.00 kB was not met by 888.17 kB with a total of 894.17 kB.Warning: /home/node/front-end/src/app/capacity/capacity.component.less exceeded maximum budget. Budget 6.00 kB was not met by 888.32 kB with a total of 894.32 kB.Warning: /home/node/front-end/src/app/rec-rbs/rec-rbs.component.less exceeded maximum budget. Budget 6.00 kB was not met by 888.32 kB with a total of 894.32 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/button/button.component.less exceeded maximum budget. Budget 6.00 kB was not met by 879 bytes with a total of 6.86 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/dropdown/dropdown.component.less exceeded maximum budget. Budget 6.00 kB was not met by 887 bytes with a total of 6.87 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/progress-bar/progress-bar.component.less exceeded maximum budget. Budget 6.00 kB was not met by 20.59 kB with a total of 26.59 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/accordion/accordion.component.less exceeded maximum budget. Budget 6.00 kB was not met by 44.15 kB with a total of 50.15 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/checkbox/checkbox.component.less exceeded maximum budget. Budget 6.00 kB was not met by 37.46 kB with a total of 43.46 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/date/datepicker.component.less exceeded maximum budget. Budget 6.00 kB was not met by 33.58 kB with a total of 39.58 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/dialog/dialog.component.less exceeded maximum budget. Budget 6.00 kB was not met by 32.63 kB with a total of 38.63 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/gauge/gauge.component.less exceeded maximum budget. Budget 6.00 kB was not met by 44.68 kB with a total of 50.68 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/input/input.component.less exceeded maximum budget. Budget 6.00 kB was not met by 55.21 kB with a total of 61.21 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/radio/radio-button.component.less exceeded maximum budget. Budget 6.00 kB was not met by 35.13 kB with a total of 41.13 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/syntax-highlight/syntax-highlight.component.less exceeded maximum budget. Budget 6.00 kB was not met by 47.50 kB with a total of 53.50 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/table/table.component.less exceeded maximum budget. Budget 6.00 kB was not met by 64.46 kB with a total of 70.46 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/switch/switch.component.less exceeded maximum budget. Budget 6.00 kB was not met by 44.72 kB with a total of 50.72 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/tooltip/tooltip.component.less exceeded maximum budget. Budget 6.00 kB was not met by 49.01 kB with a total of 55.01 kB.
m
Warning: /home/node/front-end/src/app/eds-angular/lib/components/tabs/tabs.component.less exceeded maximum budget. Budget 6.00 kB was not met by 43.55 kB with a total of 49.55 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/tree/tree.component.less exceeded maximum budget. Budget 6.00 kB was not met by 46.27 kB with a total of 52.27 kB.Warning: /home/node/front-end/src/app/eds-angular/lib/components/select/select.component.css exceeded maximum budget. Budget 6.00 kB was not met by 6.92 kB with a total of 12.92 kB.Warning: /home/node/front-end/src/app/eds-angular/test.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.Warning: /home/node/front-end/src/app/eds-angular/lib/angular.module.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.Warning: /home/node/front-end/src/environments/environment.prod.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.Warning: /home/node/front-end/src/environments/environment.test.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

打包结束会有一个dist目录

nginx容器部署web

编写dockerfile

# 基础镜像
FROM nginx
# 挂载目录
VOLUME /home/deploy/frontend/
# 创建目录
RUN mkdir -p /home/deploy/frontend/
# 指定路径
WORKDIR /home/deploy/frontend/
# 复制conf文件到路径
COPY ./nginx.conf /etc/nginx/nginx.conf
# 复制html文件到路径
COPY ./dist /home/deploy/frontend/
#指定暴露端口
EXPOSE 80

nginx配置文件修改location 模块地址改成你项目地址
构建镜像目录的时候需要有nginx.conf 和dist项目包

构建容器

dcoker built -t nginx-web:1.0.0 .docker run -it -d --name nginx-web-test -p 30005:80 -v /root/Lijunbao/dockerfile/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/deploy/frontend/dist/rvc-frontend/:/home/deploy/frontend/dist/rvc-frontend/ nginx-web:1.0.0这里挂载目录需要写到/rvc-frontend/目录

node+nginx-web部署相关推荐

  1. 一文搞懂使用Nginx服务器部署前端Web项目

    1 Nginx简介与安装 概要 Nginx 简介 Nginx 架构说明 Nginx 基础配置与使用 1.1 Nginx 简介 Nginx是一个高性能WEB服务器,除它之外Apache.Tomcat.J ...

  2. docker+nginx+node+jenkins从零开始部署你的前端服务

    前言 如果你不甘于做一个纯粹的页面仔,想了解一个web应用从编写到到发布到用户可见的全过程,或是想自己玩一点新东西,突破原有的技术圈层,那么本文将是一个很好的入门指南.笔者将从实战入手,尽可能细致地结 ...

  3. Nginx搭建部署Web服务器并与NFS结合搭建负载均衡服务器

    Nginx搭建部署Web服务器并与NFS结合搭建负载均衡服务器 一.搭建NginxWeb服务器     此种方式是用yum安装Nginx,为保证安装成功需在安装之前提前安装epel扩展源.     用 ...

  4. Docker部署Django+Mysql+uWSGI+Nginx Web应用 - 笔记更新2022-01-04

    Docker 部署Django+Mysql+uWSGI+Nginx Web应用 Change logs更新记录 2022/1/4 fixed web access problem of wide ar ...

  5. python supervisor flask_Python Web 部署:Nginx Gunicorn Supervisor Flask部署笔记

    python web 部署 web开发中,各种语言争奇斗艳,web的部署方面,却没有太多的方式.简单而已,大概都是 nginx 做前端代理,中间 webservice 调用程序脚本.大概方式:ngin ...

  6. python supervisor flask_python web 部署:nginx + gunicorn + supervisor + flask 部署笔记

    分享一篇文章,原文来自:python web 部署. Python web 部署 web开发中,各种语言争奇斗艳,web的部署方面,却没有太多的方式.简单而已,大概都是 nginx 做前端代理,中间 ...

  7. Nginx的部署与配置

    Nginx 简介 Nginx是一款自由的.开源的.高性能的HTTP服务器和 反向代理 服务器:同时也是一个IMAP.POP3.SMTP代理服务器:Nginx可以作为一个HTTP服务器进行网站的发布处理 ...

  8. nginx怎么部署php项目,nginx怎么正确部署前端项目

    目的: nginx部署打包成为dist的前端项目 (学习视频分享:php视频教程) 相关知识:docker 安装与使用 docker pull nginx docker run --restart=o ...

  9. Node.js 指南(Docker化Node.js Web应用程序)

    Docker化Node.js Web应用程序 此示例的目的是向你展示如何将Node.js应用程序放入Docker容器中,该指南旨在用于开发,而不用于生产部署,本指南还假设你有一个有效的Docker安装 ...

  10. 在nginx上部署vue项目(history模式);

    在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...

最新文章

  1. 【CF EDU59 E】 Vasya and Binary String (DP)
  2. ​​清华大学举办疫情防控期间首场在线学位论文答辩
  3. stm32 文件系统dma大小_「正点原子NANO STM32F103开发板资料连载」第二十二章 DMA 实验...
  4. .net数据根据字段进行分类(linq语句)
  5. TCP/IP详解--学习笔记(8)-DNS域名系统
  6. ML之xgboost:基于xgboost(5f-CrVa)算法对HiggsBoson数据集(Kaggle竞赛)训练(模型保存+可视化)实现二分类预测
  7. linux内核中的 哈希表_Linux内核中的设备模型及SCSI示例解析
  8. pythonapi是什么意思_python api是什么
  9. 数据结构-线性表(栈与队列的特殊性)
  10. 【ArcGIS微课1000例】0015:ArcGIS如何创建/自定义快捷键?
  11. 编写Eclipse插件教程–第1部分
  12. LeetCode 2139. 得到目标值的最少行动次数(贪心)
  13. AI时代的稀缺人才:解读数据科学家成长的4个阶段
  14. 【LeetCode】7. Reverse Integer
  15. 2016年程序员如何提高自己的方法有哪些?
  16. 函数__内置函数(reversed,slice,format,ord,chr,ascii,repr)递归,迭代,二分法
  17. ENVI裁剪遥感图像
  18. Java 第十一次作业
  19. 优动漫PAINT是什么?有哪些功能和特色
  20. 让对方计算机死机的代码,微信让对方死机代码是什么?一串代码卡死微信

热门文章

  1. 好的质量+数量 = 健康的创作者生态
  2. MacOS 配置 Fvm环境
  3. CT三维重建基本后处理方法
  4. 0.96寸oled显示坏苹果(badapple)
  5. Matlab imshow(f,G)函数使用时出现错误
  6. IntelliJ idea 配置文件ascii码转换
  7. 研发运维一体化平台是什么?众安用保险科技助力行业精细化运营
  8. 使用OpenCV打开RAW文件
  9. 最值问题—粒子群算法(PSO)python实现
  10. 使用deepdive来做因子图推理