build.sh 3.02 KB
Newer Older
Erick Hitter's avatar
Erick Hitter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/env bash

set -e
set -x

# Log when the build occurred.
date
echo ""

# Capture our starting point for easier navigation.
OG_DIR=$(pwd)
export OG_DIR
echo "$OG_DIR"
echo ""

# Common paths.
17 18 19
NGINX_ARTIFACT_PATH="$OG_DIR/artifacts"
export NGINX_ARTIFACT_PATH

20
NGINX_BUILT_BINARY_PATH="${NGINX_ARTIFACT_PATH}/nginx_${RELEASE_CODE_NAME}_${NGINX_TAG}_${OPENSSL_TAG}"
21 22 23 24
export NGINX_BUILT_BINARY_PATH

mkdir -p "$NGINX_ARTIFACT_PATH"

Erick Hitter's avatar
Erick Hitter committed
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
NGINX_SRC_DIR="$OG_DIR/src/nginx"
export NGINX_SRC_DIR

mkdir -p "$NGINX_SRC_DIR"

OPENSSL_DIR="$OG_DIR/src/openssl"
export OPENSSL_DIR

NGX_BROTLI_DIR="$OG_DIR/src/ngx_brotli"
export NGX_BROTLI_DIR

NGINX_CT_DIR="$OG_DIR/src/nginx_ct"
export NGINX_CT_DIR

# Dependency: OpenSSL
echo ""
echo "DEPENDENCY: OpenSSL AT $OPENSSL_TAG"
git clone -q --recursive --depth 1 https://github.com/openssl/openssl.git -b "$OPENSSL_TAG" "$OPENSSL_DIR"

# Dependency: ngx_brotli (no tagged releases)
echo ""
echo "DEPENDENCY: ngx_brotli"
git clone -q --recursive --depth 1 https://github.com/google/ngx_brotli.git "$NGX_BROTLI_DIR"

# Dependency: nginx-ct
echo ""
echo "DEPENDENCY: nginx-ct AT $NGINX_CT_TAG"
git clone -q --recursive --depth 1 https://github.com/grahamedgecombe/nginx-ct.git -b "$NGINX_CT_TAG" "$NGINX_CT_DIR"

# nginx from git mirror
echo ""
echo "CLONING nginx FROM GIT MIRROR AT $NGINX_TAG"
git clone -q --recursive --depth 1 https://github.com/nginx/nginx.git -b "$NGINX_TAG" "$NGINX_SRC_DIR"

# Configure nginx
echo ""
echo "CONFIGURE NGINX"
cd "$NGINX_SRC_DIR" || exit 1

./auto/configure \
    --prefix=/etc/nginx \
    --sbin-path=/usr/sbin/nginx \
    --conf-path=/etc/nginx/nginx.conf \
    --error-log-path=/var/log/nginx/error.log \
    --http-log-path=/var/log/nginx/access.log \
    --pid-path=/var/run/nginx.pid \
    --lock-path=/var/run/nginx.lock \
    --http-client-body-temp-path=/var/cache/nginx/client_temp \
    --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
    --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
    --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
    --http-scgi-temp-path=/var/cache/nginx/scgi_temp \
    --user=www-data \
    --group=www-data \
    --with-http_ssl_module \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_flv_module \
    --with-http_mp4_module \
    --with-http_gunzip_module \
    --with-http_gzip_static_module \
    --with-http_random_index_module \
    --with-http_secure_link_module \
    --with-http_stub_status_module \
    --with-http_auth_request_module \
    --with-threads \
    --with-stream \
    --with-stream_ssl_module \
    --with-http_slice_module \
    --with-mail \
    --with-mail_ssl_module \
    --with-file-aio \
    --with-http_v2_module \
    --with-openssl="$OPENSSL_DIR" \
    --add-module="$NGX_BROTLI_DIR" \
    --add-module="$NGINX_CT_DIR"

# Build nginx
echo ""
echo "BUILDING NGINX"
make

if [[ ! -f "$NGINX_SRC_DIR/objs/nginx" ]]; then
    exit 1
fi

Erick Hitter's avatar
Erick Hitter committed
113 114
cd "$NGINX_SRC_DIR/objs"
./nginx -V
115

Erick Hitter's avatar
Erick Hitter committed
116
cp "$NGINX_SRC_DIR/objs/nginx" "$NGINX_BUILT_BINARY_PATH"