jgrenon / angular-desktop-app

This is a simple application skeleton to create desktop application using AngularJS. This application is using node-webkit as our desktop host, bower to install client-side libraries as well as normal npm modules as supported by node-webkit.
MIT License
237 stars 57 forks source link

Cross-platform build targets via VM #8

Closed talss89 closed 10 years ago

talss89 commented 10 years ago

Currently, the grunt-node-webkit-builder module can download and install all flavours of node-webkit (linux64/32,win,mac), but there seems to be a big problem with npm modules which use node-gyp or similar compilation steps in the install process. node-gyp can only compile (without big mods) for the current platform, which makes creating a production package pointless for any target other than your host system.

I use Vagrant (the vm manager - http://www.vagrantup.com/) a lot in day to day web development. The great thing is that the Vagrantfile (which describes the VM and provides some great chef / puppet automation) is tiny and is easily included in the skeleton. It should allow us to build for true foreign platforms (ie. 32 bit on 64 bit host, mac on windows etc).

There's probably a whole load of unit-testing coolness to be had also.

Here's what I propose:

The build will appear in the releases/ directory, but will have been built on a different platform, so any node-gyp stuff will work.

Provisioning closed-source OS's

It'll take a bit of messing around to build for OS X or Windows as foreign targets as you'll likely need an OEM install CD to create the VM. Possibly even need VM reconfiguration (running OSX on our ESXi server took a lot of effort).

Here's some notes for future reference:

jgrenon commented 10 years ago

That sound a lot of moving parts and lot of potential problems to pre-build for all platforms. Actually, before going this way, I’ld like to discuss this particular issue with the guys from node-webkit. They have a nw-gyp compiler, I’m not sure why, but sounds like they do some compiling on their own.

For me the natural approach would be to have a first time installation task that would be run just once and would perform all required compilation for the target platform and restart the app (if required). That could avoid to prebuilt and package everything (smaller executables) and still support all platforms. Force the presence of node-gyp, npm, etc. which might not be what we want though.

Another thought is : do this really has to be automated? Anyway, any one using this seed will likely be testing their app on all target platforms so, maybe it’s better just for them to clone their git repo and execute your nice grunt tasks manually in their VM/box? They need to have a box / vm anyway to at least see what their app is looking on this platform (minimal testing).

Unless of course, you need something like you describe quickly, in which case, let’s go with that, it will surely benefits someone else too!

Joel

On Monday, February 3, 2014 at 16:03, Tom Lawton wrote:

Currently, the grunt-node-webkit-builder module can download and install all flavours of node-webkit (linux64/32,win,mac), but there seems to be a big problem with npm modules which use node-gyp or similar compilation steps in the install process. node-gyp can only compile (without big mods) for the current platform, which makes creating a production package pointless for any target other than your host system. I use Vagrant (the vm manager - http://www.vagrantup.com/) a lot in day to day web development. The great thing is that the Vagrantfile (which describes the VM and provides some great chef / puppet automation) is tiny and is easily included in the skeleton. It should allow us to build for true foreign platforms (ie. 32 bit on 64 bit host, mac on windows etc). There's probably a whole load of unit-testing coolness to be had also. Here's what I propose: Vagrantfiles for each target host in subdirectories vagrant up called in each sub-directory by Grunt will provision a new VM and bring it up chef will install node, npm, and will mount our releases/ folder, and make a copy of src/ excluding node_modules to the VM disk. Grunt connects to the VM over SSH / winRM and executes grunt build inside the VM Grunt then frees the VM with vagrant suspend

The build will appear in the releases/ directory, but will have been built on a different platform, so any node-gyp stuff will work. Provisioning closed-source OS's It'll take a bit of messing around to build for OS X or Windows as foreign targets as you'll likely need an OEM install CD to create the VM. Possibly even need VM reconfiguration (running OSX on our ESXi server took a lot of effort). Here's some notes for future reference: http://grahamgilbert.com/blog/2013/08/23/creating-an-os-x-base-box-for-vagrant-with-packer/ https://github.com/WinRb/vagrant-windows

— Reply to this email directly or view it on GitHub (https://github.com/jgrenon/angular-desktop-app/issues/8).

talss89 commented 10 years ago

I think I lost sight of the typical use case for this project on reflection. I'm using it at the moment to build prototype software - the people I'm working with aren't that computer literate and run a variety of OS's, spread over the country. I just need to churn out binaries and it's understood I'm not guaranteeing they'll run. Sounds like chaos, and it is.

I'll just stick with a manual build process for this particular job - there's no need to add bloaty code, I agree. It's bad practice to introduce this as a quick fits-all solution.

jgrenon commented 10 years ago

ok cool. Happy that this is useful to you BTW. I’m using it also for 2 customer products. I’ll share more code as I go.
Joel

On Monday, February 3, 2014 at 16:37, Tom Lawton wrote:

I think I lost sight of the typical use case for this project on reflection. I'm using it at the moment to build prototype software - the people I'm working with aren't that computer literate and run a variety of OS's, spread over the country. I just need to churn out binaries and it's understood I'm not guaranteeing they'll run. Sounds like chaos, and it is. I'll just stick with a manual build process for this particular job - there's no need to add bloaty code, I agree. It's bad practice to introduce this as a quick fits-all solution.

— Reply to this email directly or view it on GitHub (https://github.com/jgrenon/angular-desktop-app/issues/8#issuecomment-34003129).