将天然气项目部署到Azure网站 [英] Deploy gulp project to azurewebsites
问题描述
我的项目看起来像这样:
├──bower.json
├──src
│├──bower_components
│├──images
│├──index.html
│├──scripts.min.js
│└──styles.min.css
├──gulpfile.js
├──index .html
├──node_modules
│├──gulp-module-1
│└──gulp-module-2
├──package.json
└──README
我用'gulp serve'在localhost上构建它。如何在FTP服务器(azurewebsites)上托管?要上传什么?
请先看看评论!下面的答案只是针对您的 gulp serve
仅用于编译脚本的情况。如果您的网站正在启动Web服务器,则无需在下面尝试。 b
Azure Web App又名Azure网站)由 Kudu 提供支持。
您可以在Kudu中设置一个自定义部署脚本,方法是将 .deployment
和 deployment.sh
添加到你的项目的根源。每当你推送新的提交到库时,Kudu都会运行你的部署脚本。 ( 注意:FTP上传不会触发部署)
$ b
示例 .deployment
:
[config]
command = bash ./deploy.sh
示例 deploy.sh
(修改后的博客文章版本)
#部署
#----------
echo处理node.js gulp部署。
#1.选择节点版本
selectNodeVersion
#2.如果[-e$ DEPLOYMENT_SOURCE / package.json]安装npm包
;然后
eval $ NPM_CMD安装
exitWithMessageOnErrornpm failed
fi
#3.安装bower软件包
if [-e$ DEPLOYMENT_SOURCE / bower .json];然后
eval $ NPM_CMD安装bower
exitWithMessageOnError正在安装bower失败
./node_modules/.bin/bower安装
exitWithMessageOnErrorbower失败
fi
#4.如果[-e$ DEPLOYMENT_SOURCE / gulpfile.js]运行建立
的gulp;然后
eval $ NPM_CMD安装gulp
exitWithMessageOnError安装gulpfailed
./node_modules/.bin/gulp服务
exitWithMessageOnErrorgulp失败
fi
#5. KuduSync到目标
$ KUDU_SYNC_CMD-v 500 -f$ DEPLOYMENT_SOURCE / dist-t$ DEPLOYMENT_TARGET-n$ NEXT_MANIFEST_PATH-p$ PREVIOUS_MANIFEST_PATH-i .git; .hg; .deployment; deploy.sh
exitWithMessageOnErrorKudu与目标同步失败
进一步阅读:
使用Git部署的Microsoft Azure Web App(网站)自定义部署脚本
My project looks something like this:
├── bower.json
├── src
│ ├── bower_components
│ ├── images
│ ├── index.html
│ ├── scripts.min.js
│ └── styles.min.css
├── gulpfile.js
├── index.html
├── node_modules
│ ├── gulp-module-1
│ └── gulp-module-2
├── package.json
└── README
And I build it on localhost by 'gulp serve'. How can I host in on ftp server (azurewebsites)? What to upload?
Please look at the comment first! Below answer is just for the case that your gulp serve
is used for compiling script only. If your gulp is starting a web server, you need not to try below.
Azure Web App (aka Azure Web Sites) is backed by Kudu.
You may set up a custom deployment script in Kudu by adding a .deployment
and deployment.sh
to the root of your project. Every time when you push new commit to repository, Kudu will run your deployment script. (Note: FTP upload will not trigger deployment)
Sample .deployment
:
[config]
command = bash ./deploy.sh
Sample deploy.sh
(modified version from the blog post below)
# Deployment
# ----------
echo Handling node.js gulp deployment.
# 1. Select node version
selectNodeVersion
# 2. Install npm packages
if [ -e "$DEPLOYMENT_SOURCE/package.json" ]; then
eval $NPM_CMD install
exitWithMessageOnError "npm failed"
fi
# 3. Install bower packages
if [ -e "$DEPLOYMENT_SOURCE/bower.json" ]; then
eval $NPM_CMD install bower
exitWithMessageOnError "installing bower failed"
./node_modules/.bin/bower install
exitWithMessageOnError "bower failed"
fi
# 4. Run gulp for build
if [ -e "$DEPLOYMENT_SOURCE/gulpfile.js" ]; then
eval $NPM_CMD install gulp
exitWithMessageOnError "installing gulpfailed"
./node_modules/.bin/gulp serve
exitWithMessageOnError "gulp failed"
fi
# 5. KuduSync to Target
"$KUDU_SYNC_CMD" -v 500 -f "$DEPLOYMENT_SOURCE/dist" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
exitWithMessageOnError "Kudu Sync to Target failed"
Further reading:
Git and Grunt Deploy to Windows Azure
Custom Deployment Scripts For Microsoft Azure Web App (Website) Using Git Deployment
这篇关于将天然气项目部署到Azure网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!