2019-03-07 21:38:47 +08:00
|
|
|
# Dockerfile - alpine
|
|
|
|
# https://github.com/openresty/docker-openresty
|
|
|
|
|
|
|
|
ARG RESTY_IMAGE_BASE="alpine"
|
2020-02-03 23:18:37 +08:00
|
|
|
ARG RESTY_IMAGE_TAG="3.11"
|
2019-03-07 21:38:47 +08:00
|
|
|
|
|
|
|
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG}
|
|
|
|
|
|
|
|
LABEL maintainer="Evan Wies <evan@neomantra.net>"
|
|
|
|
|
|
|
|
# Docker Build Arguments
|
2020-02-03 23:18:37 +08:00
|
|
|
ARG RESTY_IMAGE_BASE="alpine"
|
|
|
|
ARG RESTY_IMAGE_TAG="3.11"
|
|
|
|
ARG RESTY_VERSION="1.15.8.2"
|
|
|
|
ARG RESTY_OPENSSL_VERSION="1.1.1c"
|
|
|
|
ARG RESTY_PCRE_VERSION="8.43"
|
|
|
|
ARG RESTY_J="1"
|
2019-03-07 21:38:47 +08:00
|
|
|
ARG RESTY_CONFIG_OPTIONS="\
|
2020-02-03 23:18:37 +08:00
|
|
|
--with-compat \
|
2019-03-07 21:38:47 +08:00
|
|
|
--with-file-aio \
|
|
|
|
--with-http_addition_module \
|
|
|
|
--with-http_auth_request_module \
|
|
|
|
--with-http_dav_module \
|
|
|
|
--with-http_flv_module \
|
|
|
|
--with-http_geoip_module=dynamic \
|
|
|
|
--with-http_gunzip_module \
|
|
|
|
--with-http_gzip_static_module \
|
|
|
|
--with-http_image_filter_module=dynamic \
|
|
|
|
--with-http_mp4_module \
|
|
|
|
--with-http_random_index_module \
|
|
|
|
--with-http_realip_module \
|
|
|
|
--with-http_secure_link_module \
|
|
|
|
--with-http_slice_module \
|
|
|
|
--with-http_ssl_module \
|
|
|
|
--with-http_stub_status_module \
|
|
|
|
--with-http_sub_module \
|
|
|
|
--with-http_v2_module \
|
|
|
|
--with-http_xslt_module=dynamic \
|
|
|
|
--with-ipv6 \
|
|
|
|
--with-mail \
|
|
|
|
--with-mail_ssl_module \
|
|
|
|
--with-md5-asm \
|
|
|
|
--with-pcre-jit \
|
|
|
|
--with-sha1-asm \
|
|
|
|
--with-stream \
|
|
|
|
--with-stream_ssl_module \
|
|
|
|
--with-threads \
|
|
|
|
"
|
|
|
|
ARG RESTY_CONFIG_OPTIONS_MORE=""
|
2020-02-03 23:18:37 +08:00
|
|
|
ARG RESTY_LUAJIT_OPTIONS="--with-luajit-xcflags='-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'"
|
|
|
|
|
2019-03-07 21:38:47 +08:00
|
|
|
ARG RESTY_ADD_PACKAGE_BUILDDEPS=""
|
|
|
|
ARG RESTY_ADD_PACKAGE_RUNDEPS=""
|
|
|
|
ARG RESTY_EVAL_PRE_CONFIGURE=""
|
|
|
|
ARG RESTY_EVAL_POST_MAKE=""
|
|
|
|
|
2020-02-03 23:18:37 +08:00
|
|
|
# These are not intended to be user-specified
|
|
|
|
ARG _RESTY_CONFIG_DEPS="--with-pcre \
|
|
|
|
--with-cc-opt='-DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' \
|
|
|
|
--with-ld-opt='-L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' \
|
|
|
|
"
|
|
|
|
|
|
|
|
LABEL resty_image_base="${RESTY_IMAGE_BASE}"
|
|
|
|
LABEL resty_image_tag="${RESTY_IMAGE_TAG}"
|
2019-03-07 21:38:47 +08:00
|
|
|
LABEL resty_version="${RESTY_VERSION}"
|
|
|
|
LABEL resty_openssl_version="${RESTY_OPENSSL_VERSION}"
|
|
|
|
LABEL resty_pcre_version="${RESTY_PCRE_VERSION}"
|
|
|
|
LABEL resty_config_options="${RESTY_CONFIG_OPTIONS}"
|
|
|
|
LABEL resty_config_options_more="${RESTY_CONFIG_OPTIONS_MORE}"
|
2020-02-03 23:18:37 +08:00
|
|
|
LABEL resty_config_deps="${_RESTY_CONFIG_DEPS}"
|
2019-03-07 21:38:47 +08:00
|
|
|
LABEL resty_add_package_builddeps="${RESTY_ADD_PACKAGE_BUILDDEPS}"
|
|
|
|
LABEL resty_add_package_rundeps="${RESTY_ADD_PACKAGE_RUNDEPS}"
|
|
|
|
LABEL resty_eval_pre_configure="${RESTY_EVAL_PRE_CONFIGURE}"
|
|
|
|
LABEL resty_eval_post_make="${RESTY_EVAL_POST_MAKE}"
|
|
|
|
|
|
|
|
|
|
|
|
RUN apk add --no-cache --virtual .build-deps \
|
|
|
|
build-base \
|
2020-02-03 23:18:37 +08:00
|
|
|
coreutils \
|
2019-03-07 21:38:47 +08:00
|
|
|
curl \
|
|
|
|
gd-dev \
|
|
|
|
geoip-dev \
|
|
|
|
libxslt-dev \
|
|
|
|
linux-headers \
|
|
|
|
make \
|
|
|
|
perl-dev \
|
|
|
|
readline-dev \
|
|
|
|
zlib-dev \
|
|
|
|
${RESTY_ADD_PACKAGE_BUILDDEPS} \
|
|
|
|
&& apk add --no-cache \
|
|
|
|
gd \
|
|
|
|
geoip \
|
|
|
|
libgcc \
|
|
|
|
libxslt \
|
|
|
|
zlib \
|
|
|
|
${RESTY_ADD_PACKAGE_RUNDEPS} \
|
|
|
|
&& cd /tmp \
|
|
|
|
&& if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \
|
2020-02-03 23:18:37 +08:00
|
|
|
&& cd /tmp \
|
2019-03-07 21:38:47 +08:00
|
|
|
&& curl -fSL https://www.openssl.org/source/openssl-${RESTY_OPENSSL_VERSION}.tar.gz -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
|
|
|
|
&& tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
|
2020-02-03 23:18:37 +08:00
|
|
|
&& cd openssl-${RESTY_OPENSSL_VERSION} \
|
|
|
|
&& if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.1" ] ; then \
|
|
|
|
echo 'patching OpenSSL 1.1.1 for OpenResty' \
|
|
|
|
&& curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.1.1c-sess_set_get_cb_yield.patch | patch -p1 ; \
|
|
|
|
fi \
|
|
|
|
&& if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.0" ] ; then \
|
|
|
|
echo 'patching OpenSSL 1.1.0 for OpenResty' \
|
|
|
|
&& curl -s https://raw.githubusercontent.com/openresty/openresty/ed328977028c3ec3033bc25873ee360056e247cd/patches/openssl-1.1.0j-parallel_build_fix.patch | patch -p1 \
|
|
|
|
&& curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.1.0d-sess_set_get_cb_yield.patch | patch -p1 ; \
|
|
|
|
fi \
|
|
|
|
&& ./config \
|
|
|
|
no-threads shared zlib -g \
|
|
|
|
enable-ssl3 enable-ssl3-method \
|
|
|
|
--prefix=/usr/local/openresty/openssl \
|
|
|
|
--libdir=lib \
|
|
|
|
-Wl,-rpath,/usr/local/openresty/openssl/lib \
|
|
|
|
&& make -j${RESTY_J} \
|
|
|
|
&& make -j${RESTY_J} install_sw \
|
|
|
|
&& cd /tmp \
|
2019-03-07 21:38:47 +08:00
|
|
|
&& curl -fSL https://ftp.pcre.org/pub/pcre/pcre-${RESTY_PCRE_VERSION}.tar.gz -o pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
|
|
|
&& tar xzf pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
2020-02-03 23:18:37 +08:00
|
|
|
&& cd /tmp/pcre-${RESTY_PCRE_VERSION} \
|
|
|
|
&& ./configure \
|
|
|
|
--prefix=/usr/local/openresty/pcre \
|
|
|
|
--disable-cpp \
|
|
|
|
--enable-jit \
|
|
|
|
--enable-utf \
|
|
|
|
--enable-unicode-properties \
|
|
|
|
&& make -j${RESTY_J} \
|
|
|
|
&& make -j${RESTY_J} install \
|
|
|
|
&& cd /tmp \
|
|
|
|
&& curl -fSL https://github.com/openresty/openresty/releases/download/v${RESTY_VERSION}/openresty-${RESTY_VERSION}.tar.gz -o openresty-${RESTY_VERSION}.tar.gz \
|
2019-03-07 21:38:47 +08:00
|
|
|
&& tar xzf openresty-${RESTY_VERSION}.tar.gz \
|
|
|
|
&& cd /tmp/openresty-${RESTY_VERSION} \
|
2020-02-03 23:18:37 +08:00
|
|
|
&& eval ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} ${RESTY_LUAJIT_OPTIONS} \
|
2019-03-07 21:38:47 +08:00
|
|
|
&& make -j${RESTY_J} \
|
|
|
|
&& make -j${RESTY_J} install \
|
|
|
|
&& cd /tmp \
|
|
|
|
&& if [ -n "${RESTY_EVAL_POST_MAKE}" ]; then eval $(echo ${RESTY_EVAL_POST_MAKE}); fi \
|
|
|
|
&& rm -rf \
|
2020-02-03 23:18:37 +08:00
|
|
|
openssl-${RESTY_OPENSSL_VERSION}.tar.gz openssl-${RESTY_OPENSSL_VERSION} \
|
2019-03-07 21:38:47 +08:00
|
|
|
pcre-${RESTY_PCRE_VERSION}.tar.gz pcre-${RESTY_PCRE_VERSION} \
|
2020-02-03 23:18:37 +08:00
|
|
|
openresty-${RESTY_VERSION}.tar.gz openresty-${RESTY_VERSION} \
|
2019-03-07 21:38:47 +08:00
|
|
|
&& apk del .build-deps \
|
2020-02-03 23:18:37 +08:00
|
|
|
&& mkdir -p /var/run/openresty \
|
2019-03-07 21:38:47 +08:00
|
|
|
&& ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \
|
|
|
|
&& ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log
|
|
|
|
|
|
|
|
# Add additional binaries into PATH for convenience
|
|
|
|
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
|
|
|
|
|
|
|
|
CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"]
|
|
|
|
|
|
|
|
# Use SIGQUIT instead of default SIGTERM to cleanly drain requests
|
|
|
|
# See https://github.com/openresty/docker-openresty/blob/master/README.md#tips--pitfalls
|
|
|
|
STOPSIGNAL SIGQUIT
|