Deploy your JET app to your Raspberry Pi

Deploying your JET application in an automated way to your Pi (or other Linux based OS) is pretty easy.

First of all; What didn’t work for me was installing jet-cli on my Pi, some dependencies are not available for the ARM-based SoC but luckily there other possibilities!

What I will demonstrate here is how you can deploy your JET web application from your development machine straight to your Pi, using only 1 command.

I have done this using a Grunt module named grunt-scp which allows you to use SCP (which makes use of the SSH protocol) to copy your web folder to your Pi.
Installing grunt-scp is easy.

npm install grunt-scp -D

The next step is to modify the existing Gruntfile.js (should be in your root directory). We will add a config block and create a new task (ps: the complete gruntfile.js can be found at the bottom).

Note that you need to modify the host, username and password. 
You can use your default pi user, but for the sake of security it’s better to create a new user without root privileges (but not required of course).
The cwd block is what folder we are going to copy, which in our case will be the generated web folder. 
The pkg block point to the main package.json file, which is handy when you want to store some config variables in there, like I did for the dest attribute (the destination folder on our Pi). <%= pkg.scpInfo.folderName %> points to my package.json file where I added:

"scpInfo": {
"folderName": "/var/www/pm/html/"

Next up is loading the grunt-scp task (in our Gruntfile.js) and load our config object.


The final step is to register a new custom task. I have named it deploy and the task will run the provided ojet build:release task and after that our scp task (you can add more tasks of course).

grunt.registerTask("deploy", "Deploy completed", function (buildType) {['oraclejet-build:release','scp']);

When we now run the following command from our develop machine:

grunt deploy

The application will be build (in release ‘mode’) and then be deployed to our Raspberry Pi!

Pro tip!

Use NGINX as your HTTP-server / reverse proxy to easily host your own site. In combination with Let’s Encrypt you can get a free SSL-certificate (be sure to check out Certbot as well).