2016-04-22 2 views
0

Какие изменения мне необходимо сделать, чтобы на самом деле запустить успешную сборку и разместить мой сайт на bluemix?Развертывание и запуск сервера grunt на IBM 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'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 
+0

Вы уже пробовали нажать приложение в Bluemix? Какие ошибки вы получили или что не работает? – opiethehokie

+0

Запуск приложения с помощью команды: «node_modules/.bin/grunt serve» может решить вашу проблему. https://developer.ibm.com/answers/questions/25856/how-to-deploy-a-web-app-based-on-grunt/ – vmovva

+0

По-видимому, у меня нет узлов_модулей ....... –

ответ

2

Несколько предложений при работе с узлом приложений и Bluemix:

  1. Чтобы запустить приложение узла, рекомендуется использовать npm start и указать сценарий в package.json.
  2. Если вашему приложению необходимо создать активы, укажите, как это сделать в сценарии postinstall в package.json. Например, если вы используете Gulp и ваша главная задача build вы будете иметь что-то вроде:

    "postinstall": "gulp build" 
    
  3. При работе в 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.

Смежные вопросы