vue+nginx+docker 的前端项目部署方案

Docker镜像+nginx 部署 vue 项目的方法 一、打包vue项目   在开发完的vue项目输入如下命名,打包生成dist文件夹 yarn build / npm run build   此时根目录会多出一个文件夹:dist文件夹,里面就是我们要发布的东西。   如果将该dist目录整个传到服务器上,部署成静态资源站点就能直接访问到该项目。 二、获取nginx 镜像   nginx 是一个高性能的HTTP和反向代理服务器,此处我们选用 nginx 镜像作为基础来构建我们的vue应用镜像。   在终端输入: docker pull nginx   即可以获取到nginx镜像。   Docker镜像是一个特殊的文件系统,除了提供容器运行时 立即下载

前后分离的项目,前端工程师就会面临一个问题:如何部署前端项目?。
因为我用的是vue,就在此基础上谈谈我的部署方案。
首先想到的就是将项目打包后用nginx发布出来就好了。
为什么不直接npm run dev?且不说性能问题,关键是在window上开发的代码放到linux上不一定能跑起来啊。npm install? 不存在的,因为我要部署的环境基本都是内网。
也是因为部署环境基本是内网,也没有考虑直接在服务器上安装nginx的方案。(关间是太懒,不想换一个地方就安装一次nginx啊)。所以看上了咋们这后端已经‘如日中天’的docker。

好了, 废话不多说了。直接来吧
准备工作
os: centos 7
docker-ce(-ce就是社区版,不要钱~ ~)。

安装docker
yum install docker
一般就安装完成了,就是这个easy有木有。(内网环境的docker以后再来说,主要是后端小伙伴已经吧docker装上啦~)
启动一下服务

systemctl start docker
安装nginx镜像

docker pull nginx
2019-04-28-2

然后查看一下你的镜像

docker images

2019-04-28-3

好了, 现在你的服务器上就有了一个nginx的docker镜像。

部署项目
把你的项目打开,ls一下啦。

2019-04-28-4

项目怎么来的就不说了,你会发现你项目里少了两个东西,一个是Dockerfile,另一个是dist。
Dockerfile没有的话好办,直接创建一个

vi Dockerfile

进去过后填入下面的内容

FROM nginx:latest
MAINTAINER xx
COPY dist/ /usr/share/nginx/html/
第一行写的是设置基础镜像,也就是我们刚刚pull下来的nginx镜像,
第二行是写一个作者,写上自己的邮箱就好滴啦,
第三行的意思就是将dist文件夹下面的内容拷贝到/usr/share/nginx/html/这个目录下。
这个目录是不是很眼熟?这个路径就是nginx一般的项目地址路径。还记得nginx的测试页面在哪儿吗,就是这个路径下的index.html啦。

没有dist文件夹怎么办?更简单啦,vue项目下npm run build一下下啦。一般来说,项目成熟了部署的时候就不带源码了,直接带这个文件夹到地方部署就好了嘛。

好了 准备开始创建自己的镜像了
在Dockerfile的目录下执行

docker build -t xxx .

xxx 是你镜像的名字。 特别注意后页面那个点不能省略

2019-04-28-5

然后在docker images 一下,你就能看到自己创建的镜像了。
然后执行命令创建容器

docker run -d --name xx -p 8848:80 xxx

-d:代表后台启动
–name xx:这是创建的容器名称
-p 8848:80: 是将nginx的80映射到你服务器的8848端口(注意你服务器的端口是否开放8848,其他端口也可以)
xxx:是刚刚创建的镜像名称

然后执行docker ps

2019-04-28-6

然后就能看到你创建的容器了。
最后打开浏览器输入你的服务器ip端口号就行了

2019-04-28-7

基本的部署就完成啦。

Unity基础篇-----Input输入 2、Input.GetTouch()方法,主要用于移动端开发使用,此方法主要获取触摸屏幕的操作数据,首先通过Input.touchCount这个方法获取到手指触摸屏幕的次数,通过GetTouch方法传输触摸次数,调用Touch结构判断手指的状态来是否为设定的状态,符合的话则执行相关内容。参数(“Horizontal”)表示左右的值,值为-1时,表示你在一直按下左方向对应的按键、设备类型为手柄时,表示你把推杆推到了最左边,为0时为默认位置,手柄中对应正中间,为1时与-1时对应的情况正好相反。 阅读详情

相关推荐

Isaacgym使用操作指南

Isaac Gym 是一个强大的仿真工具,特别适合那些需要进行大规模并行仿真和训练的机器人和强化学习任务。通过 GPU 加速、深度学习集成和丰富的物理仿真能力,Isaac Gym 能够显著提高仿真和训练效率,是机器人学和 AI 研究中的一大利器。

Tony Wey的博客 1万+

使用Docker+Nignx部署vue项目

本篇博客介绍了大致流程是在docker内运行nginx环境,然后通过数据持久化,将打包好的vue应用部署在docker内的nginx内,这里就需要我们有Docker、Nginx、Vue前置知识了,如果对这三样都很陌生的话最好先去熟悉一下,否则会很难受。

一个非常Cool的人 6466

python数据处理(一)——如何用python实现excel功能

python如何实现excel的数据提取、指标构建,进行透视分析。

一名数据分析师 2710

Docker Nginx容器部署vue项目

nigx容器部署vue项目

囚徒之困 1237

疾病负担研究(GBD)——如何使用joinpoint软件计算AAPC

疾病负担研究(GBD)——如何使用joinpoint软件计算AAPC

weixin_44240228的博客 1万+

从零到一:用Verilog和Quartus构建智能交通灯系统的实战指南

本文详细介绍了如何使用Verilog和Quartus Prime从零开始构建智能交通灯系统。通过分步指导,包括状态机设计、时序控制、数码管显示等核心模块实现,并结合ModelSim仿真验证,帮助FPGA初学者掌握数字电路设计的关键技术。文章还提供了实际部署到FPGA开发板的调试技巧和进阶优化方案。

weixin_29172201的博客 477

Docker+Nginx部署Vue3+SpringBoot项目

本篇记录如何在云服务器上使用Docker通过Nginx部署Vue3+SpringBoot项目。项目部署的方法有很多种,例如:宝塔面板快速部署、编写Dockerfile文件构建镜像容器部署,而我介绍的方法其实都是一个道理,通过修改Nginx的nginx.conf配置文件找到项目路径。

学如逆水行舟,不进则退! 1135

【VS Code+Verilog+Vivado使用】(1)常用插件

VS Code + Verilog + Vivado联合使用说明

XDUryan的博客 5640

docker部署vue项目(vue + docker + nginx)

docker部署vue项目(vue + docker + nginx)

qq_35911118的博客 3033

PyCharm + Anaconda虚拟环境:完美配置PySide6开发三件套(Designer/UIC/RCC)的避坑指南

本文详细介绍了如何在PyCharm和Anaconda虚拟环境中配置PySide6开发三件套(Designer/UIC/RCC),提供从环境准备到工具集成的完整解决方案。通过清晰的路径定位和PyCharm外部工具配置指南,帮助开发者快速搭建高效的Python GUI开发环境,避免常见配置陷阱。

weixin_28828243的博客 339

激光可燃气体传感器DIY指南:从TDLAS原理到STM32实战(附代码)

本文详细介绍了如何DIY激光可燃气体传感器,从TDLAS原理到STM32实战,包括硬件选型、光路搭建、电子系统设计和嵌入式软件开发。通过TDLAS技术实现高灵敏度甲烷检测,适合工业安全和环境监测应用。附有完整代码和实用调试技巧,帮助开发者快速掌握光学气体检测技术。

fanta的博客 444

Docker简单粗暴的部署Vue项目详解(Docker+Nginx+Vue文件),适合第一次部署

Docker是流行的容器引擎,通过Docker部署项目/服务已经是流行的方式;Nginx是高性能的Web服务器,大厂都在用。显然,作为初学者来说,如果有Vue项目,通过Docker+Nginx的方式部署到服务器上,是一个简单、粗暴、合理的选择,还能学到很多东西。 但是这三样内容,其实并不在一本教材上,可能需要看三本书才能做好。并且三个东西结合,可能会有一些坑和思路上的选择, 笔者在部署时也有遇到,因此写了一篇文章专门来讨论,算是比较详细的理解和教程,欢迎讨论。 Docker简单粗暴的部署Vue项目详解(Do

一只有点酸的程序员 的博客 3663

LCD工程师必看:Pixelclock、Mipi Clk计算全解析(附实用公式)

本文为LCD工程师详细解析了像素时钟(Pixelclock)与MIPI时钟(Mipi Clk)的核心计算方法。文章从时序参数构成入手,通过实战公式推导,系统阐述了从屏幕分辨率、刷新率到最终MIPI速率的高效计算链路,并提供了实用的调试思路与排查清单,帮助工程师快速解决画面撕裂、闪烁等常见问题。

weixin_29266679的博客 393

利用Docker部署Springboot项目 + vue+nginx+docker 的前端项目部署方案

码一下大佬的链接:https://blog.youkuaiyun.com/dhaiuda/article/details/82228186 Docker安装部署JDK:https://blog.youkuaiyun.com/Goodbye_Youth/article/details/94746808

Yuudachi的博客 1403

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

docker + nginx 部署vuejs3.0项目

https://www.cnblogs.com/longdb/p/10770661.html

weixin_43742121的博客 319

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Vue3 前端项目 Docker 容器化部署教程

本教程详细介绍了如何使用Docker和Nginx部署Vue3项目。主要内容包括:1)通过.dockerignore文件排除不必要的文件;2)采用多阶段构建的Dockerfile,先用Node构建项目再用Nginx提供服务;3)配置Nginx处理静态资源、路由历史模式、API反向代理及优化设置。教程提供了完整的配置文件和关键点说明,帮助开发者实现容器化部署,包含构建缓存优化、健康检查、安全配置等功能。最终项目结构清晰,部署配置集中管理。

deary 2120

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Docker 容器部署SpringBoot + Vue项目

使用 docker 容器部署SpringBoot+Vue前后端分离的项目。中间踩坑无数,特此记录一下,仅供学习和参考。

qq_39249627的博客 2302

使用Docker部署前端和后端项目

本文详细介绍了使用Docker容器化部署Vue+SpringBoot全栈项目的完整方案。通过Docker Compose编排管理前端(Vue+Nginx)、后端(SpringBoot)、PostgreSQL和Redis服务,构建自定义桥接网络实现容器间互通。重点讲解了Dockerfile编写、配置文件优化、数据卷持久化等关键技术,并提供了常见问题解决方案。该方案能有效解决环境不一致问题,简化部署流程,提升服务可用性,适用于中小型前后端分离项目。文中还推荐了docker.aityp.com镜像加速工具,帮助提

m0_68069969的博客 1317

Docker 部署 spring boot + Vue 项目实战

title: Docker 部署 spring + Vue 项目实战 date: 2021-5-23 updated: 2021-5-23 tags: Linux Docker docker-compose Vue categories: Docker Docker 部署 spring + Vue 项目实战 一、整体架构 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zc4dmXfZ-1653215702239)(docker%E5%AE%9E%E6%88%98/.

qq_44128703的博客 630

Vue3前端项目Docker容器化部署工作报告

项目采用Vue3+TS+Vite技术栈,通过Docker和Nginx实现生产级部署方案

qq_45161108的博客 1333

docker配置nginx,并部署多个项目

基于开发需要需要使用Docker安装nginx,并部署多个前端项目。

qq_50661854的博客 2488

Nginx 部署前端项目实战指南

本文介绍了如何利用Nginx部署Vue等前端项目并实现API代理转发。主要内容包括:1) 前端打包上传至服务器;2) Nginx基础配置实现静态资源访问;3) 解决单页应用刷新404问题的try_files配置;4) 通过proxy_pass实现API反向代理,并详细解释了斜杠用法的差异;5) 性能优化措施如Gzip压缩和缓存策略。文章提供了完整的Nginx配置文件示例,涵盖静态资源服务、路由处理、API代理等核心功能,适用于前后端分离项目的生产环境部署。

rmysjm的博客 1451

Docker部署Spring Boot + Vue项目

本文的Spring Boot + Vue项目采用若依前后端分离版项目为例,使用Docker部署项目,当然读者如果使用自己的Spring Boot + Vue项目也可以,Docker部署方法一样。

2509_94002139的博客 1000

从零到一:RuoYi-Vue-Pro前端项目Docker化部署全攻略

你是否还在为前端项目部署时的环境依赖冲突而头疼?是否经历过"在我电脑上能运行"的经典困境?Docker容器化技术彻底解决了这些问题,通过环境隔离实现"一次构建,到处运行"。本文将以RuoYi-Vue-Pro前端项目为例,提供一套完整的Docker化部署解决方案,从基础配置到高级优化,帮助你在1小时内完成从开发环境到生产环境的无缝迁移。 读完本文你将掌握: - Docker容器化部署的核心原理与优...

gitblog_01429的博客 642

新手也能5分钟搞定:本地用Docker部署前端项目全指南

Nginx 托管目录(和 Dockerfile 对应)默认访问 index.html# 关键:解决 Vue/React Router history 模式刷新 404# 可选:静态资源缓存(JS/CSS/图片等缓存 7 天,提升访问速度)expires 7d;# 可选:跨域代理(若前端需调用本地后端接口,如 http://localhost:8080/api)

qq_38388860的博客 1349

【前端vue3项目部署】操作步骤

视频源链接: https://www.bilibili.com/video/BV1YE411E7Xr/?

无邪的博客 926
上一篇: 微信小程序配置ESlint
下一篇: JSBridge 原理
leoxiaoge
博客等级 码龄10年 17粉丝 36原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

leoxiaoge

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值