简体   繁体   English

如何使用 CI/CD 在 Azure 中部署 nodejs expressjs 应用程序?

[英]How to deploy nodejs expressjs app in Azure with CI/CD?

I'm trying to deploy a nodejs with expressjs app.我正在尝试使用 expressjs 应用程序部署 nodejs。 My pipeline is this:我的管道是这样的:

在此处输入图像描述

This create a correct artifact:这将创建一个正确的工件:

在此处输入图像描述

We can check here:我们可以在这里查看:

在此处输入图像描述

Now I create this release that uses the artifact I mentioned previously:现在我创建这个版本,它使用我之前提到的工件:

在此处输入图像描述

The steps in release:发布步骤:

在此处输入图像描述

And after release executed(success) in appname.scm.azurewebsites.net in wwwroot folder I have the right files:在 wwwroot 文件夹中的 appname.scm.azurewebsites.net 中执行(成功)发布后,我有正确的文件:

在此处输入图像描述 But application never start because I never tell how start I think.但是应用程序永远不会启动,因为我从不说出我的想法。

What would I put in Post deployment action?我会在部署后操作中加入什么? node server/server.js?节点服务器/server.js? (server.js is in server folder), npm start? (server.js 在服务器文件夹中),npm 启动? In my package.json if I use npm start, then it going to run node server/server.js.在我的 package.json 中,如果我使用 npm 启动,那么它将运行 node server/server.js。 Because in local, if I will run my app I have to execute npm start or node server/server.js因为在本地,如果我要运行我的应用程序,我必须执行 npm start 或 node server/server.js

In the package.json file, normally you set the main file, "main": "server.js" , in your case I think you should define main as "main": "server.js" and move the server.js file from the server directory to project root directory .package.json文件中,通常您设置主文件"main": "server.js" ,在您的情况下我认为您应该将 main 定义为"main": "server.js"并将 server.js 文件从服务器目录到项目root directory

If you look at the log stream, normally to start the project, azure runs node server or something you defined in the package.json as main.如果您查看日志 stream,通常启动项目,azure 运行node server或您在package.json中定义为主要的东西。

I have pasted some parts of the azure log stream here so you can see what happens in the azure:我在这里粘贴了 azure 日志 stream 的一些部分,这样您就可以看到 azure 中发生了什么:

2022-05-09T18:19:04.222521897Z # Enter the source directory to make sure the script runs where the user expects
2022-05-09T18:19:04.222528898Z cd "/home/site/wwwroot"
2022-05-09T18:19:04.222535898Z
2022-05-09T18:19:04.222542298Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2022-05-09T18:19:04.222548498Z if [ -z "$PORT" ]; then
2022-05-09T18:19:04.222554799Z      export PORT=8080
2022-05-09T18:19:04.222561899Z fi
2022-05-09T18:19:04.222783509Z
2022-05-09T18:19:04.222805710Z node server.js

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

相关问题 nodejs expressjs 应用程序。 如何部署到服务器? - nodejs expressjs app. How deploy to a server? Azure DevOps CI/CD - Angular 项目 - nodeJS - Azure DevOps CI/CD - Angular Project - nodeJS 如何将NodeJs应用程序部署到Azure Web应用程序 - How to deploy a NodeJs app to azure web app 如何在 TypeScript 到 Azure 中部署 ExpressJS? - how to deploy ExpressJS in TypeScript to Azure? 在基于 Windows 的 Azure 应用服务上部署服务器端 NodeJS 应用(CI/CD 使用 Azure DevOps) - Deploying server-side NodeJS app on Windows-based Azure App Service (CI/CD Using Azure DevOps) 如何将NodeJs应用程序从Bitbucket部署到Azure - How to deploy nodeJs app from Bitbucket to Azure Gitlab CI/CD - 在 Azure 上部署节点应用程序 Linux WebApp - Gitlab CI/CD - deploy node application on Azure Linux WebApp nodejs:如何在 Azure 上部署自定义 SDK 和 nodejs 应用程序 - nodejs: how to deploy a custom SDK along with the nodejs app on Azure 无法在Azure上部署NodeJS应用 - Fail to deploy a NodeJS app on azure 如何使用Kubernetes和Gitlab CI / CD在Google Cloud Platform中部署登台? - How to deploy staging in Google Cloud Platform with Kubernetes and Gitlab CI/CD?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM