lundi 12 mai 2014

Basic Commands with CloudFoundry on IBM BLuemix



Upload am App:



cf push myAppName --no-manifest --no-start -c "node app.js"
cf start myAppName

Change route :

cf unmap-route gymbirdsmobile ng.bluemix.net -n gymbirdsmobile

cf map-route gymbirdsmobiletmp ng.bluemix.net -n gymbirdsmobile


Rename App :

cf rename gymbirdstmp gymbirds

Update App  :

i use Grunt to automate these tasks, with these command i can do an update with 2sec downtime, it need to be fixed by IBM

cf push gymbirdsmobiletmp --no-manifest --no-start -c "node app.js" 
// upload the new version

cf start gymbirdsmobiletmp 
// start it

cf unmap-route gymbirdsmobile ng.bluemix.net -n gymbirdsmobile 
// unmap original route

cf map-route gymbirdsmobiletmp ng.bluemix.net -n gymbirdsmobile 
// map the original route to the new

cf rename gymbirdsmobile gymbirdsmobileLast 
// rename the last app

cf rename gymbirdsmobiletmp gymbirdsmobile 
// rename the app uploaded to gymbirdsmobile

I automate there command with grunt

my Gruntfile.js :



shell: {
   pushbluemix: {
    command: function () {
    return 'cd ../dist/web/ ;cf push gymbirdstmp --no-manifest --no-start -c "node app.js"' ;
    }
   },
   startbluemix: {
    command: function () {
     return 'cd ../dist/web/ ;cf start gymbirdstmp ';
    }
   },
   startbluemixtest: {
    command: function () {
     return 'cd ../dist/web/ ;cf start gymbirdstest ';
    }
   },
   changeroutebluemix: {
    command: function () {
     pkg= grunt.file.readJSON("package.json");

     var command =
      'cf unmap-route gymbirds ng.bluemix.net -n gymbirds; ' +
// unmap route gymbirds.ng.bluemix.net
       'cf map-route gymbirdstmp ng.bluemix.net -n gymbirds; ' +
//map route gymbirds.ng.bluemix.net to gymbirds tmp
       ' cf rename gymbirds gymbirds'+ pkg.version+' ;' +    
// rename app gymbirds into gymbirdslast
 'cf rename gymbirdstmp gymbirds'; // rename gymbirdstmp to gymbirds
     return command;
    }
   },
   recoverbluemix: {
    command: function () {
     return   'cf unmap-route gymbirds ng.bluemix.net -n gymbirds; ' +
// unmap route gymbirds.ng.bluemix.net
      'cf map-route gymbirdslast ng.bluemix.net -n gymbirds; ' ;
//map route gymbirds.ng.bluemix.net to gymbirdstmp
    }
   },
   gitcommit: {
    command: function () {
     pkg= grunt.file.readJSON("package.json");

     console.dir(pkg.version);
     var version = pkg.version.split('.');
     var nb = Number(version[2]) +Number(1);
     version = version[0]+'.'+version[1]+'.'+nb;
     pkg.version = version;
     console.log(pkg.version);
     console.log(JSON.stringify(pkg));
     grunt.file.write("package.json", JSON.stringify(pkg));
     return   'git commit -a -m "PUSH '+pkg.name+' - version : ' +pkg.version+'"';

    }
   },
   gitpush: {
    command: function () {
     return   'git push origin master; git push gitlab master';
    }
    }
  }
And the tasks :

 // bluemix
 grunt.registerTask('push bluemix', [
  'shell:pushbluemix',
   'shell:startbluemix'
 ]);

 grunt.registerTask('bluemix', [
  'shell:pushbluemix',
  'shell:startbluemix',
  'shell:changeroutebluemix'
 ]);

 //git
 grunt.registerTask('git', [
  'shell:gitcommit',
  'shell:gitpush'
 ]);

 grunt.registerTask('magic', [
  'build',
  'bluemix',
  'git'
 ]);

'grunt magic' let met update the app on bluemix in One command !

Demo of the app : http://gymbirds.ng.bluemix.net/
mobile version : http://gymbirdsmobile.ng.bluemix.net

Notes :
My Webapp is based on AngularJs, i use bower, npm, grunt, yeoman,.

1 commentaire:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in IBM BLUEMIX , kindly Contact MaxMunus
    MaxMunus Offer World Class Virtual Instructor led training on IBM BLUEMIX. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 1,00,000 + trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Saurabh srivastava
    MaxMunus
    E-mail: saurabh@maxmunus.com
    Skype id: saurabhmaxmunus
    Ph:+918553576305
    www.MaxMunus.com


    RépondreSupprimer