Created
April 25, 2018 23:13
-
-
Save rafaeltuelho/628da4576ec9f34c6c28cd9e5b909ef0 to your computer and use it in GitHub Desktop.
Customized version of openshift official php s2i assemble script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
source ${PHP_CONTAINER_SCRIPTS_PATH}/common.sh | |
shopt -s dotglob | |
echo "---> CUSTOMIZED VERSION OF ASSEMBLE S2I!!! <---" | |
echo "---> Installing application source..." | |
mv /tmp/src/* ./ | |
if [ -f composer.json ]; then | |
echo "Found 'composer.json', installing dependencies using composer.phar... " | |
# Install Composer | |
TEMPFILE=$(mktemp) | |
RETRIES=6 | |
for ((i=0; i<$RETRIES; i++)); do | |
if [ -z "$COMPOSER_INSTALLER" ]; then | |
export COMPOSER_INSTALLER="https://getcomposer.org/installer" | |
fi | |
echo "Downloading $COMPOSER_INSTALLER, attempt $((i+1))/$RETRIES" | |
curl -o $TEMPFILE $COMPOSER_INSTALLER && break | |
sleep 10 | |
done | |
if [[ $i == $RETRIES ]]; then | |
echo "Download failed, giving up." | |
exit 1 | |
fi | |
php <$TEMPFILE | |
if [ "$(ls -a /tmp/artifacts/ 2>/dev/null)" ]; then | |
echo "Restoring build artifacts" | |
mv /tmp/artifacts/* $HOME/ | |
fi | |
# Change the repo mirror if provided | |
if [ -n "$COMPOSER_MIRROR" ]; then | |
./composer.phar config -g repositories.packagist composer $COMPOSER_MIRROR | |
fi | |
# Our customization starts here | |
echo -e "\n\n----------------------------------------------" | |
echo -e "try to install the composer-asset-plugin..." | |
echo -e "------------------------------------------------\n\n" | |
./composer.phar global require "fxp/composer-asset-plugin" | |
./composer.phar global show | |
# Install App dependencies using Composer | |
./composer.phar install --no-interaction --no-ansi --optimize-autoloader --no-dev | |
if [ ! -f composer.lock ]; then | |
echo -e "\nConsider adding a 'composer.lock' file into your source repository.\n" | |
fi | |
fi | |
# post-assemble files | |
process_extending_files ./php-post-assemble/ ${PHP_CONTAINER_SCRIPTS_PATH}/post-assemble/ | |
# Fix source directory permissions | |
fix-permissions ./ | |
fix-permissions ${HTTPD_CONFIGURATION_PATH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment