I'm trying to push a Node.js app with a node-jdbc module to Bluemix. This node-jdbc module requires JDK to be installed. Is there a way to push a Node.js app and also install JDK in the same runtime?
This is the solution I used to deploy a Bluemix Node.js application with node-jdbc
dependency:
1) Download a JDK package for Linux x64 (compatible with Cloud Foundry stack)
2) Install/unzip the JDK package in the root's project directory, my directory was something like this (jdk1.7.0_79
is the new directory I added):
-rwxr-xr-x@ 1 adasilva staff 436 Jan 24 18:21 README.md
drwxr-xr-x 15 adasilva staff 510 Apr 10 2015 jdk1.7.0_79
-rw-r--r--@ 1 adasilva staff 72 Jan 27 15:27 manifest.yml
-rwxr-xr-x@ 1 adasilva staff 327 Jan 27 21:21 package.json
-rwxr-xr-x@ 1 adasilva staff 4412 Jan 24 18:21 server.js
3) Now, for the buildpack to detect the Java I had to set the following environment variable:
cf set-env your-app-name JAVA_HOME /tmp/staged/app/jdk1.7.0_79
After deployment the app directory will actually be at /home/vcap/app
, but the compilation is done at staging so the directory is different
4) For runtime the application needs Java libraries, so I needed to also set another environment variable:
cf set-env your-app-name LD_LIBRARY_PATH /home/vcap/app/jdk1.7.0_79/jre/lib/amd64:/home/vcap/app/jdk1.7.0_79/jre/lib/amd64/server
Note that now I used the /home/vcap/app
since runtime will be after app is deployed.
5) Run cf restage
and cf push
again to redeploy application.