2016-04-22 6 views
0

実際にビルドを成功させ、Webサイトをbluemix上でホストするためには、どのような変更が必要ですか?IBM bluemixでgrunt serverをデプロイして実行してください

これは私の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

明らかに、私はnode_modulesを持っていません....... –

答えて

2

いくつかの提案ノード・アプリケーションとBluemixでの作業:

  1. ノードアプリケーションを起動するには、npm startを使用し、package.jsonにスクリプトを指定することをお勧めします。
  2. アプリケーションでアセットを作成する必要がある場合は、のpostinstallスクリプトでアセットを作成する方法を指定します。アプリケーションを実行するホストとポートを持つことになりますBluemix VCAP_APP_HOSTVCAP_APP_PORTで実行している場合

    "postinstall": "gulp build" 
    
  3. :あなたはGulpを使用していて、あなたの主なタスクがある場合たとえば、build次のようなものを持っています。


下記のファイルは、上記の修正があります。

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にあります。

関連する問題