I have a Python application in Openshift, with Python 3.3 and PostgreSQL cartridges. The Python cartridge is running Django 1.8, based off the template on the Website.
Recently, I started using Gulp to automate my build, and while it's worked great on my local machine, I can't figure out what to do to use it in Openshift. I have django-gulp installed so it just runs whenever I use
So, after trying to work this out for a while, I've finally figured out a solution. This is a bit convoluted, but it does work:
cd $OPENSHIFT_HOMEDIR/app_root/dependencies; wget https://nodejs.org/dist/v6.3.0/node-v6.3.0-linux-x64.tar.xz; tar xf node-v6.3.0-linux-x64.tar.xz; rm node-v6.3.0-linux-x64.tar.xzInstall the dev version. DO NOT install the stable version as that'll burn through your inodes like nothing else.
export PATH="$OPENSHIFT_HOMEDIR/app_root/dependencies/node_modules/.bin/:$OPENSHIFT_HOMEDIR/app_root/dependencies/node/bin/:$PATH"Environment variables get reset whenever you disconnect from the server. You can change them permanently with
rhc env set, but as this is only used before deployment, I recommend sticking this in the
export NPM_CONFIG_USERCONFIG=$OPENSHIFT_HOMEDIR/app-root/build-dependencies/.npmrc. Once again, I recommend doing this in the pre_build hook.
npm config set cache "$OPENSHIFT_HOMEDIR/app_root/dependencies/.npm
npm install! Install the packages you need. Use the
--prefixflag to install to the
npm install gulpWITHOUT the prefix flag.
gulp! However, your gulpfile will not not find the modules unless you edit your gulpfile to link to the dependencies folder you have set up. So instead of
require('gulp-cssnano'), you'd have
require([OPENSHIFT_HOMEDIR]/app_root/dependencies/node_modules/gulp-cssnano). I keep a separate gulpfile for Openshift to maintain my sanity.