简体   繁体   English

一步部署Node.js应用

[英]Deployment of node.js app in one step

We just finished developing a node.js application which includes a Restful API and a Mssql database . 我们刚刚完成了一个node.js应用程序的开发,该应用程序包括一个Restful API和一个Mssql数据库。

I will need to deploy the app in in-house servers of companies having Windows 2008 and windows 2012 environments 我将需要在具有Windows 2008和Windows 2012环境的公司的内部服务器中部署该应用程序

What i want to achieve : 我想实现的目标:

  • The best case is to make the deployment in an one-step procedure . 最好的情况是一步一步进行部署。

What im currently doing : 我目前正在做什么:

  • Clone the project in a dir 在目录中克隆项目

  • Run npm install ( Best case scenario is to have all dependencies in a folder to avoid problems with versions or npm ) 运行npm install(最好的情况是将所有依赖项放在一个文件夹中,以避免版本或npm出现问题)

  • Deploy the db using a script 使用脚本部署数据库

  • Start processes with pm2 process manager 使用pm2流程管理器启动流程

Is there anyway to pack all these steps in a simple step ? 无论如何,是否可以将所有这些步骤打包到一个简单的步骤中? Something alternative to docker for example ? 例如,可以替代docker吗? (I can't use docker because is not compatible with most of the OS ) (由于与大多数操作系统不兼容,所以我不能使用docker)

Is there anyway to pack all these steps in a simple step ? 无论如何,是否可以将所有这些步骤打包到一个简单的步骤中?

Yes. 是。 You can write a script that does all of that for you. 您可以编写一个脚本来完成所有这些工作。

Even without writing such a script you can combine the first two steps easily. 即使没有编写这样的脚本,您也可以轻松地将前两个步骤组合在一起。 To simplify the first two steps you could make your project globaly installable with npm install --global . 为了简化前两个步骤,您可以使用npm install --global将项目npm install --global You could install your project that is hosted on GitHub just by doing: 您只需执行以下操作即可安装托管在GitHub上的项目:

npm install -g username/repo

and it will install your project and all of its dependencies. 它将安装您的项目及其所有依赖项。

You could also use a private package on npm or even a private npm registry for that. 您也可以在npm上使用私有包,甚至使用私有npm注册表。

You could install both the start scripts and the db deploy scripts that way as well in a single step, because your module can install multiple executables. 您也可以在一个步骤中同时安装启动脚本和数据库部署脚本,因为您的模块可以安装多个可执行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM