forked from ryandotsmith/nginx-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build_nginx.sh
executable file
·50 lines (38 loc) · 1.7 KB
/
build_nginx.sh
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
#!/bin/bash
#
# Requires 'vulcan' to be installed and a build server created.
# https://devcenter.heroku.com/articles/buildpack-binaries
NGINX_VERSION=1.5.2
PCRE_VERSION=8.21
OPENSSL_VERSION=1.0.1e
nginx_tarball_url=http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
#pcre_tarball_url=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${PCRE_VERSION}.tar.bz2
pcre_tarball_url=http://garr.dl.sourceforge.net/project/pcre/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.bz2
openssl_tarball_url=http://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
temp_dir=$(mktemp -d /tmp/vulcan_nginx.XXXXXXXXXX)
cleanup() {
echo "Cleaning up $temp_dir"
cd /
rm -rf "$temp_dir"
}
trap cleanup EXIT
script_dir=$(cd $(dirname $0); pwd)
vulcan_archive_result=$temp_dir/nginx-${NGINX_VERSION}-built-with-vulcan.tar.gz
untarring_dir=$temp_dir/untarring
nginx_binary_drop_dir=$script_dir/../bin
cd $temp_dir
echo "Temp dir: $temp_dir"
echo "Downloading $nginx_tarball_url"
curl $nginx_tarball_url | tar xf -
echo "Downloading $pcre_tarball_url"
(cd nginx-${NGINX_VERSION} && curl $pcre_tarball_url | tar xf -)
echo "Downloading $openssl_tarball_url"
(cd nginx-${NGINX_VERSION} && curl $openssl_tarball_url | tar xf -)
vulcan build -o ${vulcan_archive_result} -s nginx-${NGINX_VERSION} -v -p /tmp/nginx -c "./configure --with-http_ssl_module --with-openssl=openssl-${OPENSSL_VERSION} --with-pcre=pcre-${PCRE_VERSION} --prefix=/tmp/nginx && make install"
echo "Extracting the nginx binary into the buildback"
mkdir -p $untarring_dir
cd $untarring_dir
tar -xf $vulcan_archive_result
mkdir -p $nginx_binary_drop_dir
cp sbin/nginx $nginx_binary_drop_dir
echo "Copied the nginx binary into $(cd $nginx_binary_drop_dir; pwd)"