52 lines
1.4 KiB
Bash
Executable file
52 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# For SCL enablement
|
|
source .bashrc
|
|
|
|
set -e
|
|
|
|
echo "---> Copying application source ..."
|
|
cp -Rf /tmp/src/* ./
|
|
|
|
if [ -f setup.py ]; then
|
|
echo "---> Installing application ..."
|
|
python setup.py install --user
|
|
elif [ -f requirements.txt ]; then
|
|
echo "---> Installing dependencies ..."
|
|
pip install --user -r requirements.txt
|
|
fi
|
|
|
|
# set permissions for any installed artifacts
|
|
chmod -R og+rwx /opt/openshift
|
|
|
|
|
|
# Support for Django
|
|
|
|
# Take shallowest manage.py script
|
|
MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' -printf '%d\t%P\n' | sort -nk1 | cut -f2 | head -1)
|
|
|
|
if pip show -q django && [ -f "$MANAGE_FILE" ]; then
|
|
set +e
|
|
|
|
# Check if collectstatic can be run.
|
|
python $MANAGE_FILE collectstatic --dry-run --noinput &> /dev/null && RUN_COLLECTSTATIC=true
|
|
|
|
# Collect assets if settings seems okay.
|
|
if [ "$RUN_COLLECTSTATIC" ]; then
|
|
echo "---> Collecting static assets ..."
|
|
python $MANAGE_FILE collectstatic --noinput 2>&1 | sed '/^Copying/d;/^$/d;/^ /d'
|
|
|
|
[ $? -ne 0 ] && {
|
|
echo "ERROR: 'manage.py collectstatic' failed. See the build logs for more info."
|
|
exit 1
|
|
} || true
|
|
else
|
|
echo "WARNING: 'manage.py collectstatic' ignored. To debug, run:"
|
|
echo " $ python $MANAGE_FILE collectstatic --noinput"
|
|
echo "Ignore this warning if you're not serving static files with Django."
|
|
fi
|
|
fi
|
|
|
|
|
|
# remove pip temporary directory
|
|
rm -rf /tmp/pip_build_default
|