2016-04-22 12 views
0

Welche Änderungen muss ich vornehmen, um einen erfolgreichen Build auszuführen und meine Website auf bluemix zu hosten?Bereitstellen und Ausführen von grunt Server auf IBM bluemix

Im Moment ist dies meine Gruntfile.js, manifest.yml und package.json. Der Basisordner 'App' ist eine Schräg Anwendung -

 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

Haben Sie schon versucht, die App auf Bluemix zu schieben? Welche Fehler hast du bekommen oder was hat nicht funktioniert? – opiethehokie

+0

Starten Sie Ihre Anwendung mit dem Befehl: "node_modules/.bin/grunt serve", um das Problem zu lösen. https://developer.ibm.com/answers/questions/25856/how-to-deploy-a-web-app-based-on-grunt/ – vmovva

+0

Anscheinend habe ich keine Knoten_Module ....... –

Antwort

2

paar Vorschläge, wenn sie mit Knoten-Anwendungen und Bluemix arbeiten:

  1. Um eine Knotenanwendung zu starten, wird empfohlen, npm start zu verwenden und das Skript in package.json anzugeben.
  2. Wenn Ihre Anwendung Assets erstellen muss, geben Sie im Skript package.json an, wie dies im Skript postinstall zu tun ist. Wenn Sie zum Beispiel verwenden Gulp und Ihre Hauptaufgabe ist es build Sie haben so etwas wie:

    "postinstall": "gulp build" 
    
  3. Wenn in Bluemix VCAP_APP_HOST und VCAP_APP_PORT ausgeführt wird den Host und Port, wo Ihre Anwendung ausgeführt wird.


Die Dateien unten haben die Updates oben erwähnt:

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']); 
}; 

Nachdem die oben erwähnten Veränderungen zu tun, öffnen Sie den Projektordner und führen npm start. Wenn es lokal funktioniert, wird es in Bluemix.

Verwandte Themen