forked from heroku/heroku-buildpack-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile
executable file
·88 lines (70 loc) · 2.16 KB
/
compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/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
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
# Normally slugignore and pruning .git/DS_Store are done in the slug compiler,
# but since the PHP buildpack moves everything out of $BUILD_DIR into
# www/ we can't rely on that implementation and need to duplicate it here.
if [ -r $BUILD_DIR/www/.slugignore ]; then
unset GIT_DIR
cd www
if [ "$(git ls-files -c -o -i --exclude-from=.slugignore)" != "" ]; then
echo "-----> Deleting files matching .slugignore patterns."
git ls-files -z -c -o -i --exclude-from=.slugignore | xargs -0 rm
fi
cd ..
fi
if [ -d $BUILD_DIR/www/.git ]; then
rm -rf $BUILD_DIR/www/.git
fi
if [ "$(find $BUILD_DIR -name .DS_Store -print0)" != "" ]; then
find $BUILD_DIR -name .DS_Store -print0 | xargs -0 rm
fi
# clean the cache
rm -rf $CACHE_DIR/*