为了在bluemix上运行一个成功的构建和托管我的网站,我需要做哪些改变?
现在,这是我的Gruntfile.js,manifest.yml和package.json。基本文件夹'app‘是一个角度应用程序-
module.exports = function(grunt){
grunt.initConfig({
connect: {
server: {
options: {
port: 9000,
base: 'app',
keepalive: true,
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['connect']);
};package.json
{
"name": "dummy",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {"grunt-cli": "^1.2.0",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.10.1"
}
}manifest.yml
---
applications: #Reference http://docs.cloudfoundry.com/docs/using/deploying-apps/manifest.html
- name: dummy #Application Name. Unique to the user's Space
memory: 256M #The maximum memory to allocate to each application instance
instances: 1 #The number of instances of the application to start
path: ./ #Path to the application to be pushed
command: npm install && node_modules/.bin/grunt serve #The command to use to start the application发布于 2016-04-24 18:08:32
在使用节点应用程序和Bluemix时,很少有建议:
npm start并在package.json中指定脚本。postinstall脚本中指定如何在package.json中这样做。例如,如果您正在使用大口吞下,并且您的主要任务是build,那么您将得到如下内容:
“后安装”:“吞咽构建”VCAP_APP_HOST和VCAP_APP_PORT将拥有运行应用程序的主机和端口。以下文件具有上面提到的修补程序:
manifest.yml
---
applications:
- name: dummy-kartik-yadav
memory: 512M
instances: 1
path: .
command: npm startpackage.json
{
"name": "dummy",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node_modules/.bin/grunt serve",
"postinstall": "console.log('build ui assets like js, css, html...')"
},
"author": "",
"license": "ISC",
"dependencies": {
"grunt-cli": "^1.2.0",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.10.1"
}
}gruntfile.js
module.exports = function(grunt){
grunt.initConfig({
connect: {
server: {
options: {
port: process.env.VCAP_APP_PORT || 9000, # listen to the port that bluemix will assign you
base: 'app',
keepalive: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['connect']);
};完成上述更改后,打开项目文件夹并运行npm start。如果它在当地有效的话,它将在布卢米克斯。
https://stackoverflow.com/questions/36784165
复制相似问题