This repository has been archived by the owner. It is now read-only.
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 70 lines (56 sloc) 2.01 KB
#!/bin/bash
# Prevent running assemble in builders different than official STI image.
# The official nodejs:0.10-onbuild already run npm install and use different
# application folder.
[ -d "/usr/src/app" ] && exit 0
set -e
# FIXME: Linking of global modules is disabled for now as it causes npm failures
# under RHEL7
# Global modules good to have
# npmgl=$(grep "^\s*[^#\s]" ../etc/npm_global_module_list | sort -u)
# Available global modules; only match top-level npm packages
#global_modules=$(npm ls -g 2> /dev/null | perl -ne 'print "$1\n" if /^\S+\s(\S+)\@[\d\.-]+/' | sort -u)
# List all modules in common
#module_list=$(/usr/bin/comm -12 <(echo "${global_modules}") | tr '\n' ' ')
# Link the modules
#npm link $module_list
echo "---> Installing application source"
cp -Rf /tmp/src/. ./
if [ ! -z $HTTP_PROXY ]; then
echo "---> Setting npm http proxy to $HTTP_PROXY"
npm config set proxy $HTTP_PROXY
fi
if [ ! -z $http_proxy ]; then
echo "---> Setting npm http proxy to $http_proxy"
npm config set proxy $http_proxy
fi
if [ ! -z $HTTPS_PROXY ]; then
echo "---> Setting npm https proxy to $HTTPS_PROXY"
npm config set https-proxy $HTTPS_PROXY
fi
if [ ! -z $https_proxy ]; then
echo "---> Setting npm https proxy to $https_proxy"
npm config set https-proxy $https_proxy
fi
# Change the npm registry mirror if provided
if [ ! -z "$NPM_MIRROR" ]; then
echo "---> Setting the npm package mirror to $NPM_MIRROR"
npm config set registry $NPM_MIRROR
fi
if [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then
echo "---> Restoring build artifacts..."
mv /tmp/artifacts/* ./
fi
echo "---> Building your Node application from source"
npm install -s
# Fix source directory permissions
# fix-permissions ./
# Allow this script to fail without failing a build
#set +e
# Fix permissions on the given directory to allow group read/write of
# regular files and execute of directories.
#chgrp -R 0 .;
#find -L . -xtype l -exec chgrp 0 {} \;
#chmod -R g+rw .;
#find -L . -xtype l -exec chmod g+rw {} \;
#find . -type d -exec chmod g+x {} +