2019-12-19 20:34:31 +01:00
|
|
|
FROM alpine:3.11
|
2016-05-29 02:09:20 +02:00
|
|
|
|
|
|
|
ENV UID=991 GID=991
|
|
|
|
|
2020-04-15 12:43:36 +02:00
|
|
|
ARG NGINX_VERSION=1.17.10
|
2016-05-29 02:09:20 +02:00
|
|
|
ARG GPG_NGINX="B0F4 2533 73F8 F6F5 10D4 2178 520A 9993 A1C0 52F8"
|
|
|
|
ARG BUILD_CORES
|
|
|
|
|
2017-03-01 15:00:39 +01:00
|
|
|
ARG NGINX_MODULES=" \
|
|
|
|
--with-http_ssl_module \
|
|
|
|
--with-http_v2_module \
|
|
|
|
--with-http_gzip_static_module \
|
|
|
|
--with-http_stub_status_module \
|
|
|
|
--with-file-aio \
|
|
|
|
--with-threads \
|
|
|
|
--with-pcre-jit \
|
|
|
|
--without-http_ssi_module \
|
|
|
|
--without-http_scgi_module \
|
|
|
|
--without-http_uwsgi_module \
|
|
|
|
--without-http_geo_module \
|
|
|
|
--without-http_autoindex_module \
|
|
|
|
--without-http_split_clients_module \
|
|
|
|
--without-http_memcached_module \
|
|
|
|
--without-http_empty_gif_module \
|
|
|
|
--without-http_browser_module"
|
|
|
|
|
|
|
|
ARG NGINX_3RD_PARTY_MODULES=" \
|
|
|
|
--add-module=/tmp/headers-more-nginx-module \
|
|
|
|
--add-module=/tmp/ngx_brotli"
|
|
|
|
|
2017-08-08 04:54:27 +02:00
|
|
|
RUN NB_CORES=${BUILD_CORES-$(getconf _NPROCESSORS_CONF)} \
|
|
|
|
&& apk -U upgrade \
|
|
|
|
&& apk add \
|
|
|
|
${BUILD_DEPS} \
|
|
|
|
pcre \
|
|
|
|
zlib \
|
|
|
|
libgcc \
|
|
|
|
libstdc++ \
|
|
|
|
su-exec \
|
|
|
|
libressl \
|
|
|
|
bind-tools \
|
|
|
|
tini \
|
|
|
|
&& apk add -t build-dependencies \
|
2016-05-29 02:09:20 +02:00
|
|
|
build-base \
|
|
|
|
linux-headers \
|
|
|
|
ca-certificates \
|
|
|
|
automake \
|
|
|
|
autoconf \
|
|
|
|
git \
|
|
|
|
tar \
|
|
|
|
libtool \
|
|
|
|
pcre-dev \
|
|
|
|
zlib-dev \
|
|
|
|
binutils \
|
|
|
|
gnupg \
|
|
|
|
cmake \
|
2017-08-08 04:54:27 +02:00
|
|
|
go \
|
2017-03-01 15:00:39 +01:00
|
|
|
&& cd /tmp && git clone https://github.com/bagder/libbrotli --depth=1 \
|
|
|
|
&& cd libbrotli && ./autogen.sh && ./configure && make -j ${NB_CORES} && make install \
|
|
|
|
&& cd /tmp && git clone https://github.com/google/ngx_brotli --depth=1 \
|
|
|
|
&& cd ngx_brotli && git submodule update --init \
|
|
|
|
&& cd /tmp && git clone https://github.com/openresty/headers-more-nginx-module --depth=1 \
|
2016-06-30 13:00:46 +05:00
|
|
|
&& git clone https://boringssl.googlesource.com/boringssl --depth=1 \
|
2017-03-01 15:00:39 +01:00
|
|
|
&& cd boringssl \
|
2016-05-31 22:39:39 +02:00
|
|
|
&& mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. \
|
2016-05-29 12:44:53 +02:00
|
|
|
&& make -j ${NB_CORES} && cd .. \
|
2016-05-29 02:09:20 +02:00
|
|
|
&& mkdir -p .openssl/lib/ && cd .openssl && ln -s ../include && cd .. \
|
|
|
|
&& cp build/crypto/libcrypto.a build/ssl/libssl.a .openssl/lib && cd /tmp \
|
|
|
|
&& NGINX_TARBALL="nginx-${NGINX_VERSION}.tar.gz" \
|
2016-06-28 23:13:33 -07:00
|
|
|
&& wget -q https://nginx.org/download/${NGINX_TARBALL} \
|
2016-05-29 02:09:20 +02:00
|
|
|
&& echo "Verifying ${NGINX_TARBALL} using GPG..." \
|
2016-06-28 23:13:33 -07:00
|
|
|
&& wget -q https://nginx.org/download/${NGINX_TARBALL}.asc \
|
|
|
|
&& wget -q https://nginx.org/keys/mdounin.key \
|
2016-05-29 02:09:20 +02:00
|
|
|
&& gpg --import mdounin.key \
|
|
|
|
&& FINGERPRINT="$(LANG=C gpg --verify ${NGINX_TARBALL}.asc ${NGINX_TARBALL} 2>&1 \
|
|
|
|
| sed -n "s#Primary key fingerprint: \(.*\)#\1#p")" \
|
|
|
|
&& if [ -z "${FINGERPRINT}" ]; then echo "Warning! Invalid GPG signature!" && exit 1; fi \
|
|
|
|
&& if [ "${FINGERPRINT}" != "${GPG_NGINX}" ]; then echo "Warning! Wrong GPG fingerprint!" && exit 1; fi \
|
|
|
|
&& echo "All seems good, now unpacking ${NGINX_TARBALL}..." \
|
|
|
|
&& tar xzf ${NGINX_TARBALL} && cd nginx-${NGINX_VERSION} \
|
2018-09-07 15:27:07 +02:00
|
|
|
&& wget -q https://raw.githubusercontent.com/hoellen/dockerfiles/master/boring-nginx/dynamic_records.patch -O dynamic_records.patch \
|
2018-08-30 22:12:23 +02:00
|
|
|
&& patch -p1 < dynamic_records.patch \
|
2016-05-31 22:39:39 +02:00
|
|
|
&& ./configure \
|
2016-05-29 02:09:20 +02:00
|
|
|
--prefix=/etc/nginx \
|
2016-06-29 16:18:44 +02:00
|
|
|
--sbin-path=/usr/sbin/nginx \
|
2017-08-08 19:04:34 +02:00
|
|
|
--with-cc-opt="-O3 -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -Wno-deprecated-declarations -I ../boringssl/.openssl/include/" \
|
2019-02-01 09:06:59 +01:00
|
|
|
--with-ld-opt="-lrt -Wl,-Bsymbolic-functions -Wl,-z,relro -L ../boringssl/.openssl/lib" \
|
2016-05-29 02:09:20 +02:00
|
|
|
--http-log-path=/var/log/nginx/access.log \
|
|
|
|
--error-log-path=/var/log/nginx/error.log \
|
2017-03-01 15:00:39 +01:00
|
|
|
${NGINX_MODULES} \
|
|
|
|
${NGINX_3RD_PARTY_MODULES} \
|
2016-05-29 02:09:20 +02:00
|
|
|
&& make -j ${NB_CORES} && make install && make clean \
|
2016-06-29 16:18:44 +02:00
|
|
|
&& strip -s /usr/sbin/nginx \
|
2017-08-08 04:54:27 +02:00
|
|
|
&& apk del build-dependencies \
|
2016-05-30 19:43:23 +02:00
|
|
|
&& rm -rf /tmp/* /var/cache/apk/* /root/.gnupg
|
2016-05-29 02:09:20 +02:00
|
|
|
|
2017-08-08 04:54:27 +02:00
|
|
|
COPY rootfs /
|
2016-05-29 02:09:20 +02:00
|
|
|
|
|
|
|
RUN chmod +x /usr/local/bin/*
|
|
|
|
|
|
|
|
EXPOSE 8000 4430
|
|
|
|
|
2016-05-29 02:17:24 +02:00
|
|
|
VOLUME /sites-enabled /www /conf.d /passwds /certs /var/log/nginx
|
2016-05-29 02:09:20 +02:00
|
|
|
|
2016-10-11 18:59:35 +02:00
|
|
|
LABEL description="nginx built from source" \
|
2016-10-01 17:46:27 +02:00
|
|
|
openssl="BoringSSL" \
|
2017-01-19 02:31:59 +01:00
|
|
|
nginx="nginx ${NGINX_VERSION}" \
|
2017-12-22 13:02:32 +01:00
|
|
|
maintainer="hoellen <info@hoellen.eu>"
|
2016-05-29 02:09:20 +02:00
|
|
|
|
2016-09-16 17:08:06 +02:00
|
|
|
CMD ["run.sh"]
|