From d3cb013479595e9a08c1b3176fc9bc0d0a17d26d Mon Sep 17 00:00:00 2001 From: Pedro Belo Date: Wed, 14 Sep 2011 13:51:47 -0700 Subject: [PATCH] cache apache/php with the slug --- bin/compile | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/bin/compile b/bin/compile index 4c2b7ccb6..cdb02843f 100755 --- a/bin/compile +++ b/bin/compile @@ -1,6 +1,15 @@ #!/usr/bin/env bash # bin/compile +# fail fast +set -e + +# config +APACHE_VERSION="2.2.19" +APACHE_PATH="apache" +PHP_VERSION="5.3.6" +PHP_PATH="php" + BIN_DIR=$(dirname $0) BUILD_DIR=$1 CACHE_DIR=$2 @@ -10,20 +19,36 @@ LP_DIR=`cd $(dirname $0); cd ..; pwd` shopt -s dotglob cd $BUILD_DIR + +# move app things to www mkdir -p $CACHE_DIR/www mv * $CACHE_DIR/www mv $CACHE_DIR/www . -APACHE_VERSION="2.2.19" -APACHE_URL="https://s3.amazonaws.com/php-lp/apache-$APACHE_VERSION.tar.gz" -echo "-----> Bundling Apache v$APACHE_VERSION" -curl --silent --max-time 60 --location $APACHE_URL | tar xz -cp $LP_DIR/conf/httpd.conf apache/conf +# unpack cache +for DIR in $APACHE_PATH $PHP_PATH ; do + rm -rf $DIR + if [ -d $CACHE_DIR/$DIR ]; then + cp -r $CACHE_DIR/$DIR $DIR + fi +done -PHP_VERSION="5.3.6" -PHP_URL="https://s3.amazonaws.com/php-lp/php-$PHP_VERSION.tar.gz" -echo "-----> Bundling PHP v$PHP_VERSION" -curl --silent --max-time 60 --location $PHP_URL | tar xz +# install apache if needed +if [ ! -d $APACHE_PATH ]; then + APACHE_URL="https://s3.amazonaws.com/php-lp/apache-$APACHE_VERSION.tar.gz" + echo "-----> Bundling Apache v$APACHE_VERSION" + curl --silent --max-time 60 --location $APACHE_URL | tar xz +fi + +# install php if needed +if [ ! -d $PHP_PATH ]; then + PHP_URL="https://s3.amazonaws.com/php-lp/php-$PHP_VERSION.tar.gz" + echo "-----> Bundling PHP v$PHP_VERSION" + curl --silent --max-time 60 --location $PHP_URL | tar xz +fi + +# update config files +cp $LP_DIR/conf/httpd.conf $APACHE_PATH/conf cp $LP_DIR/conf/php.ini php cat >>boot.sh <