Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: abf09e1539
Fetching contributors…

Cannot retrieve contributors at this time

executable file 81 lines (65 sloc) 1.941 kb
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>
# fail fast
set -e
# config
APACHE_VERSION="2.2.22"
APACHE_PATH="apache"
PHP_VERSION="5.3.10"
PHP_PATH="php"
BIN_DIR=$(dirname $0)
BUILD_DIR=$1
CACHE_DIR=$2
LP_DIR=`cd $(dirname $0); cd ..; pwd`
# include .files when moving things around
shopt -s dotglob
cd $BUILD_DIR
# move app things to www
mkdir -p $CACHE_DIR/www
mv * $CACHE_DIR/www
mv $CACHE_DIR/www .
# keep Procfile
if [ -f www/Procfile ]; then
mv www/Procfile .
fi
APACHE_URL="https://s3.amazonaws.com/php-lp/apache-$APACHE_VERSION.tar.gz"
echo "-----> Bundling Apache version $APACHE_VERSION"
curl --silent --max-time 60 --location "$APACHE_URL" | tar xz
PHP_URL="https://s3.amazonaws.com/php-lp/php-$PHP_VERSION.tar.gz"
echo "-----> Bundling PHP version $PHP_VERSION"
curl --silent --max-time 60 --location "$PHP_URL" | tar xz
# update config files
cp $LP_DIR/conf/httpd.conf $APACHE_PATH/conf
cp $LP_DIR/conf/php.ini php
# make php available on bin
mkdir -p bin
ln -s /app/php/bin/php bin/php
# check if we have Composer dependencies
if [ -f www/composer.json ]; then
GIT_DIR_ORIG=$GIT_DIR
unset $GIT_DIR
echo "-----> Installing Composer dependencies"
COMPOSER_URL="http://getcomposer.org/composer.phar"
curl --silent --max-time 60 --location "$COMPOSER_URL" > www/composer.phar
cd www
LD_LIBRARY_PATH=$BUILD_DIR/php/ext $BUILD_DIR/php/bin/php composer.phar install -v
cd $BUILD_DIR
rm www/composer.phar
export GIT_DIR=$GIT_DIR_ORIG
fi
cat >>boot.sh <<EOF
for var in \`env|cut -f1 -d=\`; do
echo "PassEnv \$var" >> /app/apache/conf/httpd.conf;
done
touch /app/apache/logs/error_log
touch /app/apache/logs/access_log
tail -F /app/apache/logs/error_log &
tail -F /app/apache/logs/access_log &
export LD_LIBRARY_PATH=/app/php/ext
export PHP_INI_SCAN_DIR=/app/www
echo "Launching apache"
exec /app/apache/bin/httpd -DNO_DETACH
EOF
chmod +x boot.sh
# clean the cache
rm -rf $CACHE_DIR/*
Jump to Line
Something went wrong with that request. Please try again.