slush-marklogic-node
slush-marklogic-node copied to clipboard
Deploy on offline (Linux) server
There has been a few mentions internally of deployments on servers that didn't allow direct internet access. It is still possible to get it on a server by running most of the build process elsewhere..
Roughly:
- MarkLogic needs to be up and running on the server
- Make sure Node.js and npm are available on that machine as well. Node.js provides plenty docs on this.
- Get a vm of same architecture and OS
- Run at least npm install, bower install, gulp build
- Install forever and npmzip (
sudo npm install -g forever npmzip) - Create tarball of forever (
npmzip forever) - Zip the entire project folder, and transfer to offline server
- Install tarball of forever (
npmunzip forever) - Bootstrap the project with the Ruby that comes with the server (or install it, or push the config from a different server with Ruby that can access that server)
- Follow the README steps to install the middle-tier as a service
offline-npm might be a solution as well, haven't investigated yet..
I had a similar situation, developing on my laptop and then deploying to a server that doesn't allow installing node packages via npm. We were able to overcome this by using npmbox. If you have Node and npm on the target server, you can transfer and install npmbox there (there are special instructions on the npmbox page for installing npmbox on a system that isn't connected). Then on my laptop I would run npmbox to package up anything I needed, transfer it over, and run npmunbox to install it. We had success with a few packages including gulp. In my experience the latest version of npmbox didn't work but I did have success with 1.0.0 so I recommend using that version.
I recently did this for a prospect with an offline Windows server (without the need for forever). The one additional step I needed was npm install gulp ... and then I had to direct them run gulp using the direct path to the executable, though I'm sure there is a better way to handle that by setting the PATH.
And I echo the reminder to run the commands on the same operating system, since npm tries to be smart about that.
In case of hurry you could save hassle with forever or gulp, by running node boot.js --ml-host=.. --ml-port=.. --app-port=... Launch it with nohup..
Still requires a succesful gulp build local or on server..
We had some discussion in the chat room about this. @joemfb pointed out that yarn has some built-in ability to do this: https://yarnpkg.com/blog/2016/11/24/offline-mirror/
This comes up often enough that it would be good to have some built-in answer that doesn't require doing work on a VM with identical architecture and OS as the server, which I've found can be a difficult requirement for other developer teams.
Quite a bit has changed since this ticket was first created. npmbox seems the way to package npm modules these days.
I put together this wiki though, which uses none of these, and matches current stack: https://github.com/marklogic-community/slush-marklogic-node/wiki/Deploying-on-offline-servers