Bump base image (#538)
[discourse_docker.git] / image / base / install-nginx
1 #!/bin/bash
2 set -e
3
4 # version check: https://nginx.org/en/download.html
5 VERSION=1.18.0
6 HASH="4c373e7ab5bf91d34a4f11a0c9496561061ba5eee6020db272a17a7228d35f99"
7
8 apt install -y autoconf
9
10 cd /tmp
11 curl -O https://nginx.org/download/nginx-$VERSION.tar.gz
12 sha256sum nginx-$VERSION.tar.gz
13 echo "$HASH nginx-$VERSION.tar.gz" | sha256sum -c
14 tar zxf nginx-$VERSION.tar.gz
15 cd nginx-$VERSION
16
17 # nginx-common for boilerplate files etc.
18 apt install -y nginx-common libpcre3 libpcre3-dev zlib1g zlib1g-dev
19
20 cd /tmp
21 # this is the reason we are compiling by hand...
22 git clone https://github.com/google/ngx_brotli.git
23 # now ngx_brotli has brotli as a submodule
24 cd /tmp/ngx_brotli
25 git submodule update --init
26
27 cd /tmp/nginx-$VERSION
28 # ignoring depracations with -Wno-deprecated-declarations while we wait for this https://github.com/google/ngx_brotli/issues/39#issuecomment-254093378
29 ./configure --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wno-deprecated-declarations' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_v2_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module=/tmp/ngx_brotli
30
31 make install
32
33 mv /usr/share/nginx/sbin/nginx /usr/sbin
34
35 cd /
36 rm -fr /tmp/nginx
37 rm -fr /tmp/libbrotli
38 rm -fr /tmp/ngx_brotli
39 rm -fr /etc/nginx/modules-enabled/*