| 
2 | 2 | 
 
  | 
3 | 3 | set -e  | 
4 | 4 | 
 
  | 
5 |  | -mkdir -p "$1/bin/"  | 
6 |  | -cp "bin/nginx-$STACK" "$1/bin/nginx"  | 
7 |  | -cp "bin/nginx-debug-$STACK" "$1/bin/nginx-debug"  | 
8 |  | -nginx_version=$(./bin/nginx-$STACK -V 2>&1 | head -1 | awk '{ print $NF }')  | 
 | 5 | +# clean up leaking environment  | 
 | 6 | +unset GIT_DIR  | 
 | 7 | + | 
 | 8 | +# parse and derive params  | 
 | 9 | +BUILD_DIR=$1  | 
 | 10 | +CACHE_DIR=$2  | 
 | 11 | +BUILDPACK_DIR="$(dirname "$(dirname "$0")")"  | 
 | 12 | + | 
 | 13 | +mkdir -p "$BUILD_DIR/bin/"  | 
 | 14 | +mkdir -p "$BUILD_DIR/nginx"  | 
 | 15 | +tar -zxvf "nginx-$STACK".tgz -C "$BUILD_DIR/nginx"  | 
 | 16 | + | 
 | 17 | +cp "$BUILD_DIR/nginx/nginx" "$BUILD_DIR/bin/nginx"  | 
 | 18 | +cp "$BUILD_DIR/nginx/nginx-debug" "$BUILD_DIR/bin/nginx-debug"  | 
 | 19 | + | 
 | 20 | +nginx_version=$($BUILD_DIR/bin/nginx -V 2>&1 | head -1 | awk '{ print $NF }')  | 
9 | 21 | echo "-----> nginx-buildpack: Installed ${nginx_version} to app/bin"  | 
10 |  | -cp bin/start-nginx "$1/bin/"  | 
 | 22 | +cp bin/start-nginx "$BUILD_DIR/bin/"  | 
11 | 23 | echo '-----> nginx-buildpack: Added start-nginx to app/bin'  | 
12 |  | -cp bin/start-nginx-debug "$1/bin/"  | 
 | 24 | +cp bin/start-nginx-debug "$BUILD_DIR/bin/"  | 
13 | 25 | echo '-----> nginx-buildpack: Added start-nginx-debug to app/bin'  | 
14 |  | -cp bin/start-nginx-solo "$1/bin/"  | 
 | 26 | +cp bin/start-nginx-solo "$BUILD_DIR/bin/"  | 
15 | 27 | echo '-----> nginx-buildpack: Added start-nginx-solo to app/bin'  | 
16 | 28 | 
 
  | 
17 |  | -mkdir -p "$1/config"  | 
 | 29 | +mkdir -p "$BUILD_DIR/config"  | 
18 | 30 | 
 
  | 
19 |  | -if [[ ! -f $1/config/mime.types ]]; then  | 
20 |  | -	cp config/mime.types "$1/config/"  | 
 | 31 | +if [[ ! -f $BUILD_DIR/config/mime.types ]]; then  | 
 | 32 | +	cp "$BUILD_DIR/nginx/mime.types" "$BUILD_DIR/config/"  | 
21 | 33 | 	echo '-----> nginx-buildpack: Default mime.types copied to app/config/'  | 
22 | 34 | else  | 
23 | 35 | 	echo '-----> nginx-buildpack: Custom mime.types found in app/config.'  | 
24 | 36 | fi  | 
25 | 37 | 
 
  | 
26 |  | -if [[ ! -f $1/config/nginx.conf.erb ]]; then  | 
27 |  | -	cp config/nginx.conf.erb "$1/config/"  | 
 | 38 | +if [[ ! -f $BUILD_DIR/config/nginx.conf.erb ]]; then  | 
 | 39 | +	cp config/nginx.conf.erb "$BUILD_DIR/config/"  | 
28 | 40 | 	echo '-----> nginx-buildpack: Default config copied to app/config.'  | 
29 | 41 | else  | 
30 | 42 | 	echo '-----> nginx-buildpack: Custom config found in app/config.'  | 
31 | 43 | fi  | 
 | 44 | + | 
 | 45 | +# cleanup  | 
 | 46 | +rm -r "$BUILD_DIR/nginx"  | 
 | 47 | + | 
32 | 48 | exit 0  | 
0 commit comments