Reputation: 997
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?
Upvotes: 0
Views: 1612
Reputation: 1697
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
Upvotes: 3