Какие изменения я должен сделать inorder, чтобы фактически запустить успешную сборку и разместить мой сайт на bluemix?
Прямо сейчас, это мои Gruntfile.js, manifest.yml и package.json. Базовая папка "приложение" - это угловое приложение -
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 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
Несколько предложений при работе с узловыми приложениями и Bluemix:
npm start
и указать скрипт в package.json
. Если вашему приложению необходимо создавать активы, укажите, как это сделать в сценарии postinstall
в package.json
. Например, если вы используете Gulp, и ваша основная задача build
вас будет что-то вроде:
"postinstall": "gulp build"
При запуске в Bluemix VCAP_APP_HOST
и VCAP_APP_PORT
будут иметь хост и порт, на которых будет запущено ваше приложение.
В приведенных ниже файлах есть исправления, упомянутые выше:
manifest.yml
:
---
applications:
- name: dummy-kartik-yadav
memory: 512M
instances: 1
path: .
command: npm start
package.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
. Если он работает локально, он будет в Bluemix.