Ask or search…
Comment on page

How to create a VM with NodeJS and node_modules

This is an example we used for an internal project

Build the JS

$ cd project
$ docker run --rm -ti -v $(pwd):/opt/project node bash
# cd /opt/project
# npm i
# npm run build

Setup to run in a VM

$ cp .env.defaults dist/
$ cat >> << EOF
cd /opt
node /opt/index.js

Upload the node_modules

$ mksquashfs node_modules node_modules.squashfs
$ aleph file upload node_modules.squashfs
And obtain the item_hash for the next step.

Build and upload the program

$ aleph program create ../my-project/project/dist/ ""
Add volume ? [y/N] y
Description: node_modules
Mount: /opt/node_modules
Persist on VM host ? [y/N]
Ref: WWW
Use latest version ? [Y/n]
Add volume ? [y/N] y
Description: data
Mount: /data
Persist on VM host ? [y/N] y
Volume name: data
Size in MiB: 1000
Add volume ? [y/N]
Your program has been uploaded on Aleph .
Available on:
Visualise on: