FROM debian:stretch as builder
ENV NGINX_VERSION 1.15.9
ENV OPENSSL_VERSION 1.1.1b
RUN set -x \
&& openssl_url="https://www.openssl.org/source/openssl-1.1.1b.tar.gz" \
&& nginx_url="https://nginx.org/download/nginx-1.15.9.tar.gz" \
&& ngx_patch_1="https://raw.githubusercontent.com/hakasenyang/openssl-patch/89c8eedc85af4bdc8c453e3d2a9edbee77e75b96/nginx_strict-sni.patch" \
&& openssl_patch_1="https://raw.githubusercontent.com/hakasenyang/openssl-patch/89c8eedc85af4bdc8c453e3d2a9edbee77e75b96/openssl-1.1.1b-chacha_draft.patch" \
&& openssl_patch_2="https://raw.githubusercontent.com/hakasenyang/openssl-patch/89c8eedc85af4bdc8c453e3d2a9edbee77e75b96/openssl-equal-1.1.1b_ciphers.patch" \
&& apt-get update \
&& apt-get install --no-install-recommends -y build-essential curl git wget ca-certificates apt-utils apt-transport-https \
&& mkdir -p /build && cd /build \
&& curl "$openssl_url" | gzip -d | tar xf - \
&& mv openssl-1.1.1b/ openssl/ && cd openssl \
&& curl "$openssl_patch_1" | patch -p1 \
&& curl "$openssl_patch_2" | patch -p1 \
&& apt-get install zlib1g-dev libpcre3-dev -y --no-install-recommends \
&& cd /build \
&& git clone --depth=1 https://github.com/google/ngx_brotli.git ngx_br \
&& cd ngx_br && git submodule update --init --recursive \
&& cd /build \
&& curl "$nginx_url" -k -s -L | gzip -d | tar xf - \
&& mv nginx-1.15.9/ nginx/ && cd nginx/ \
&& curl "$nginx_patch_1" -s -k -L | patch -p1 \
&& ./configure \
--with-cc-opt="-O3 -fomit-frame-pointer -fstack-protector-strong" \
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed' \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--user=www-data \
--group=www-data \
--prefix=/nginx \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_v2_module \
--with-http_dav_module \
--with-http_slice_module \
--with-threads \
--with-http_addition_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_sub_module \
--with-stream=dynamic \
--with-stream_ssl_module \
--add-module=../ngx_br \
--with-openssl=../openssl \
--with-openssl-opt="no-tests" \
&& make \
&& find /build/nginx/objs/ -executable -and ! -type d -and -type f -exec strip -s {} \; \
&& make install
FROM debian:stretch as prod
COPY --from=0 /nginx /nginx
RUN set -x \
&& apt-get update \
&& apt-get install zlib1g libpcre3 -y --no-install-recommends \
&& mkdir -p /etc/ld.so.conf.d/ \
&& echo "/nginx/modules" >> /etc/ld.so.conf.d/9999-nginx.conf \
&& ldconfig \
&& mkdir -p /var/log/nginx && mkdir -p /var/www/ \
&& touch /var/log/nginx/access.log && touch /var/log/nginx/error.log \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
&& apt-get purge -y make && apt-get autoremove -y \
&& ln -sf /nginx/sbin/nginx /usr/sbin/nginx \
&& ln -sf /nginx/html /var/www/html
CMD ["nginx", "-g", "daemon off;"]
Content type
Image
Digest
Size
5.7 MB
Last updated
over 6 years ago
docker pull athenacle/nginx