-
Notifications
You must be signed in to change notification settings - Fork 329
/
package_nginx
executable file
·56 lines (44 loc) · 1.55 KB
/
package_nginx
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
#!/bin/sh
set -e
if [ "$NGINX_VERSION" == "" ]; then
echo "must set NGINX_VERSION, i.e NGINX_VERSION=1.2.0"
exit 1
fi
if [ "$AWS_ID" == "" ]; then
echo "must set AWS_ID, i.e. export AWS_ID=1BHAJK48DJFMQKZMNV93"
exit 1
fi
if [ "$AWS_SECRET" == "" ]; then
echo "must set AWS_SECRET, i.e. export AWS_SECRET=fj2jjchebsjksmMJCN387RHNjdnddNfi4jjhshh3"
exit 1
fi
if [ "$S3_BUCKET" == "" ]; then
echo "must set S3_BUCKET, i.e. S3_BUCKET=heroku-buildpack-wordpress"
exit 1
fi
PCRE_VERSION=8.32
basedir="$( cd -P "$( dirname "$0" )" && pwd )"
# make a temp directory
tempdir="$( mktemp -t nginx_XXXX )"
rm -rf $tempdir
mkdir -p $tempdir
pushd $tempdir
# download and extract nginx
curl https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tgz
tar xzvf nginx.tgz
# download and extract pcre into contrib directory
pushd nginx-$NGINX_VERSION/contrib
curl ftp:https://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${PCRE_VERSION}.tar.gz -o pcre.tgz
tar zvxf pcre.tgz
popd
# build and package nginx for heroku
vulcan build -v -s nginx-$NGINX_VERSION -o $tempdir/nginx-$NGINX_VERSION-heroku.tar.gz -p /app/vendor/nginx -c \
"./configure --prefix=/app/vendor/nginx \
--with-pcre=contrib/pcre-${PCRE_VERSION} \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_realip_module \
&& make install"
# upload to s3
$basedir/aws/s3 put $S3_BUCKET nginx-$NGINX_VERSION-heroku.tar.gz $tempdir/nginx-$NGINX_VERSION-heroku.tar.gz