|
| 1 | +# Dockerfile - Alma Linux |
| 2 | +# https://github.com/openresty/docker-openresty |
| 3 | + |
| 4 | +ARG RESTY_IMAGE_BASE="almalinux" |
| 5 | +ARG RESTY_IMAGE_TAG="10" |
| 6 | + |
| 7 | +FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} |
| 8 | + |
| 9 | +LABEL maintainer="Evan Wies <evan@neomantra.net>" |
| 10 | + |
| 11 | +# Docker Build Arguments |
| 12 | +ARG RESTY_IMAGE_BASE="almalinux" |
| 13 | +ARG RESTY_IMAGE_TAG="10" |
| 14 | +ARG RESTY_VERSION="1.29.2.3" |
| 15 | +ARG RESTY_LUAROCKS_VERSION="3.13.0" |
| 16 | + |
| 17 | +# https://github.com/openresty/openresty-packaging/blob/master/deb/openresty-openssl3/debian/rules |
| 18 | +ARG RESTY_OPENSSL_VERSION="3.5.5" |
| 19 | +ARG RESTY_OPENSSL_PATCH_VERSION="3.5.5" |
| 20 | +ARG RESTY_OPENSSL_URL_BASE="https://github.com/openssl/openssl/releases/download/openssl-${RESTY_OPENSSL_VERSION}" |
| 21 | +# LEGACY: "https://www.openssl.org/source/old/1.1.1" |
| 22 | +ARG RESTY_OPENSSL_BUILD_OPTIONS="enable-camellia enable-seed enable-rfc3779 enable-cms enable-md2 enable-rc5 \ |
| 23 | + enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method enable-md2 enable-ktls enable-fips \ |
| 24 | + " |
| 25 | + |
| 26 | + |
| 27 | +# https://github.com/openresty/openresty-packaging/blob/master/deb/openresty-pcre2/debian/rules |
| 28 | +ARG RESTY_PCRE_VERSION="10.47" |
| 29 | +ARG RESTY_PCRE_SHA256="c08ae2388ef333e8403e670ad70c0a11f1eed021fd88308d7e02f596fcd9dc16" |
| 30 | +ARG RESTY_PCRE_BUILD_OPTIONS="--enable-jit --enable-pcre2grep-jit --disable-bsr-anycrlf --disable-coverage --disable-ebcdic --disable-fuzz-support \ |
| 31 | + --disable-jit-sealloc --disable-never-backslash-C --enable-newline-is-lf --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 \ |
| 32 | + --enable-pcre2grep-callout --enable-pcre2grep-callout-fork --disable-pcre2grep-libbz2 --disable-pcre2grep-libz --disable-pcre2test-libedit \ |
| 33 | + --enable-percent-zt --disable-rebuild-chartables --enable-shared --disable-static --disable-silent-rules --enable-unicode --disable-valgrind \ |
| 34 | + " |
| 35 | + |
| 36 | +ARG RESTY_J="1" |
| 37 | + |
| 38 | +# https://github.com/openresty/openresty-packaging/blob/master/deb/openresty/debian/rules |
| 39 | +ARG RESTY_CONFIG_OPTIONS="\ |
| 40 | + --with-compat \ |
| 41 | + --without-http_rds_json_module \ |
| 42 | + --without-http_rds_csv_module \ |
| 43 | + --without-lua_rds_parser \ |
| 44 | + --without-mail_pop3_module \ |
| 45 | + --without-mail_imap_module \ |
| 46 | + --without-mail_smtp_module \ |
| 47 | + --with-http_addition_module \ |
| 48 | + --with-http_auth_request_module \ |
| 49 | + --with-http_dav_module \ |
| 50 | + --with-http_flv_module \ |
| 51 | + --with-http_gunzip_module \ |
| 52 | + --with-http_gzip_static_module \ |
| 53 | + --with-http_image_filter_module=dynamic \ |
| 54 | + --with-http_mp4_module \ |
| 55 | + --with-http_random_index_module \ |
| 56 | + --with-http_realip_module \ |
| 57 | + --with-http_secure_link_module \ |
| 58 | + --with-http_slice_module \ |
| 59 | + --with-http_ssl_module \ |
| 60 | + --with-http_stub_status_module \ |
| 61 | + --with-http_sub_module \ |
| 62 | + --with-http_v2_module \ |
| 63 | + --with-http_v3_module \ |
| 64 | + --with-http_xslt_module=dynamic \ |
| 65 | + --with-ipv6 \ |
| 66 | + --with-mail \ |
| 67 | + --with-mail_ssl_module \ |
| 68 | + --with-md5-asm \ |
| 69 | + --with-sha1-asm \ |
| 70 | + --with-stream \ |
| 71 | + --with-stream_ssl_module \ |
| 72 | + --with-stream_ssl_preread_module \ |
| 73 | + --with-threads \ |
| 74 | + " |
| 75 | +ARG RESTY_CONFIG_OPTIONS_MORE="" |
| 76 | +ARG RESTY_LUAJIT_OPTIONS="--with-luajit-xcflags='-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'" |
| 77 | +ARG RESTY_PCRE_OPTIONS="--with-pcre-jit" |
| 78 | + |
| 79 | +ARG RESTY_ADD_PACKAGE_BUILDDEPS="" |
| 80 | +ARG RESTY_ADD_PACKAGE_RUNDEPS="" |
| 81 | +ARG RESTY_EVAL_PRE_CONFIGURE="" |
| 82 | +ARG RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE="" |
| 83 | +ARG RESTY_EVAL_PRE_MAKE="" |
| 84 | +ARG RESTY_EVAL_POST_MAKE="" |
| 85 | + |
| 86 | +# These are not intended to be user-specified |
| 87 | +ARG _RESTY_CONFIG_DEPS="--with-pcre \ |
| 88 | + --with-cc-opt='-DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/pcre2/include -I/usr/local/openresty/openssl3/include' \ |
| 89 | + --with-ld-opt='-L/usr/local/openresty/pcre2/lib -L/usr/local/openresty/openssl3/lib -Wl,-rpath,/usr/local/openresty/pcre2/lib:/usr/local/openresty/openssl3/lib' \ |
| 90 | + " |
| 91 | + |
| 92 | +LABEL resty_image_base="${RESTY_IMAGE_BASE}" |
| 93 | +LABEL resty_image_tag="${RESTY_IMAGE_TAG}" |
| 94 | +LABEL resty_version="${RESTY_VERSION}" |
| 95 | +LABEL resty_luarocks_version="${RESTY_LUAROCKS_VERSION}" |
| 96 | +LABEL resty_openssl_version="${RESTY_OPENSSL_VERSION}" |
| 97 | +LABEL resty_openssl_patch_version="${RESTY_OPENSSL_PATCH_VERSION}" |
| 98 | +LABEL resty_openssl_url_base="${RESTY_OPENSSL_URL_BASE}" |
| 99 | +LABEL resty_openssl_build_options="${RESTY_OPENSSL_BUILD_OPTIONS}" |
| 100 | +LABEL resty_pcre_version="${RESTY_PCRE_VERSION}" |
| 101 | +LABEL resty_pcre_build_options="${RESTY_PCRE_BUILD_OPTIONS}" |
| 102 | +LABEL resty_pcre_sha256="${RESTY_PCRE_SHA256}" |
| 103 | +LABEL resty_config_options="${RESTY_CONFIG_OPTIONS}" |
| 104 | +LABEL resty_config_options_more="${RESTY_CONFIG_OPTIONS_MORE}" |
| 105 | +LABEL resty_config_deps="${_RESTY_CONFIG_DEPS}" |
| 106 | +LABEL resty_add_package_builddeps="${RESTY_ADD_PACKAGE_BUILDDEPS}" |
| 107 | +LABEL resty_add_package_rundeps="${RESTY_ADD_PACKAGE_RUNDEPS}" |
| 108 | +LABEL resty_eval_pre_configure="${RESTY_EVAL_PRE_CONFIGURE}" |
| 109 | +LABEL resty_eval_post_download_pre_configure="${RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE}" |
| 110 | +LABEL resty_eval_pre_make="${RESTY_EVAL_PRE_MAKE}" |
| 111 | +LABEL resty_eval_post_make="${RESTY_EVAL_POST_MAKE}" |
| 112 | +LABEL resty_luajit_options="${RESTY_LUAJIT_OPTIONS}" |
| 113 | +LABEL resty_pcre_options="${RESTY_PCRE_OPTIONS}" |
| 114 | + |
| 115 | + |
| 116 | +RUN dnf install -y \ |
| 117 | + curl \ |
| 118 | + diffutils \ |
| 119 | + gd-devel \ |
| 120 | + libxml2-devel \ |
| 121 | + libxslt-devel \ |
| 122 | + patch \ |
| 123 | + perl \ |
| 124 | + zlib-devel \ |
| 125 | + && cd /tmp \ |
| 126 | + && if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \ |
| 127 | + && curl -fSL "${RESTY_OPENSSL_URL_BASE}/openssl-${RESTY_OPENSSL_VERSION}.tar.gz" -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ |
| 128 | + && tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ |
| 129 | + && cd openssl-${RESTY_OPENSSL_VERSION} \ |
| 130 | + && if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-2) = "3." ] ; then \ |
| 131 | + echo 'patching OpenSSL 3.x for OpenResty' \ |
| 132 | + && curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \ |
| 133 | + fi \ |
| 134 | + && ./config \ |
| 135 | + shared zlib -g \ |
| 136 | + --prefix=/usr/local/openresty/openssl3 \ |
| 137 | + --libdir=lib \ |
| 138 | + -Wl,-rpath,/usr/local/openresty/openssl3/lib \ |
| 139 | + ${RESTY_OPENSSL_BUILD_OPTIONS} \ |
| 140 | + && make -j${RESTY_J} \ |
| 141 | + && make -j${RESTY_J} install_sw \ |
| 142 | + && cd /tmp \ |
| 143 | + && curl -fSL "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${RESTY_PCRE_VERSION}/pcre2-${RESTY_PCRE_VERSION}.tar.gz" -o pcre2-${RESTY_PCRE_VERSION}.tar.gz \ |
| 144 | + && echo "${RESTY_PCRE_SHA256} pcre2-${RESTY_PCRE_VERSION}.tar.gz" | shasum -a 256 --check \ |
| 145 | + && tar xzf pcre2-${RESTY_PCRE_VERSION}.tar.gz \ |
| 146 | + && cd /tmp/pcre2-${RESTY_PCRE_VERSION} \ |
| 147 | + && CFLAGS="-g -O3" ./configure \ |
| 148 | + --prefix=/usr/local/openresty/pcre2 \ |
| 149 | + --libdir=/usr/local/openresty/pcre2/lib \ |
| 150 | + ${RESTY_PCRE_BUILD_OPTIONS} \ |
| 151 | + && CFLAGS="-g -O3" make -j${RESTY_J} \ |
| 152 | + && CFLAGS="-g -O3" make -j${RESTY_J} install \ |
| 153 | + && cd /tmp \ |
| 154 | + && curl -fSL https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz -o openresty-${RESTY_VERSION}.tar.gz \ |
| 155 | + && tar xzf openresty-${RESTY_VERSION}.tar.gz \ |
| 156 | + && cd /tmp/openresty-${RESTY_VERSION} \ |
| 157 | + && if [ -n "${RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE}); fi \ |
| 158 | + && eval ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} ${RESTY_LUAJIT_OPTIONS} ${RESTY_PCRE_OPTIONS} \ |
| 159 | + && if [ -n "${RESTY_EVAL_PRE_MAKE}" ]; then eval $(echo ${RESTY_EVAL_PRE_MAKE}); fi \ |
| 160 | + && make -j${RESTY_J} \ |
| 161 | + && make -j${RESTY_J} install \ |
| 162 | + && cd /tmp \ |
| 163 | + && curl -fSL https://luarocks.github.io/luarocks/releases/luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz -o luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \ |
| 164 | + && tar xzf luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \ |
| 165 | + && cd luarocks-${RESTY_LUAROCKS_VERSION} \ |
| 166 | + && ./configure \ |
| 167 | + --prefix=/usr/local/openresty/luajit \ |
| 168 | + --with-lua=/usr/local/openresty/luajit \ |
| 169 | + --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1 \ |
| 170 | + && make build \ |
| 171 | + && make install \ |
| 172 | + && cd /tmp \ |
| 173 | + && if [ -n "${RESTY_EVAL_POST_MAKE}" ]; then eval $(echo ${RESTY_EVAL_POST_MAKE}); fi \ |
| 174 | + && rm -rf \ |
| 175 | + luarocks-${RESTY_LUAROCKS_VERSION} luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \ |
| 176 | + openssl-${RESTY_OPENSSL_VERSION}.tar.gz openssl-${RESTY_OPENSSL_VERSION} \ |
| 177 | + pcre2-${RESTY_PCRE_VERSION}.tar.gz pcre2-${RESTY_PCRE_VERSION} \ |
| 178 | + openresty-${RESTY_VERSION}.tar.gz openresty-${RESTY_VERSION} \ |
| 179 | + && if [ -n "${RESTY_ADD_PACKAGE_BUILDDEPS}" ]; then DEBIAN_FRONTEND=noninteractive apt-get remove -y --purge ${RESTY_ADD_PACKAGE_BUILDDEPS} ; fi \ |
| 180 | + && dnf clean all \ |
| 181 | + && mkdir -p /var/run/openresty \ |
| 182 | + && ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \ |
| 183 | + && ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log |
| 184 | + |
| 185 | +# Add additional binaries into PATH for convenience |
| 186 | +ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin |
| 187 | + |
| 188 | +# Add LuaRocks paths |
| 189 | +# If OpenResty changes, these may need updating: |
| 190 | +# /usr/local/openresty/bin/resty -e 'print(package.path)' |
| 191 | +# /usr/local/openresty/bin/resty -e 'print(package.cpath)' |
| 192 | +ENV LUA_PATH="/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua" |
| 193 | + |
| 194 | +ENV LUA_CPATH="/usr/local/openresty/site/lualib/?.so;/usr/local/openresty/lualib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so" |
| 195 | + |
| 196 | +# Copy nginx configuration files |
| 197 | +COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf |
| 198 | +COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf |
| 199 | + |
| 200 | +CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"] |
| 201 | + |
| 202 | +# Use SIGQUIT instead of default SIGTERM to cleanly drain requests |
| 203 | +# See https://github.com/openresty/docker-openresty/blob/master/README.md#tips--pitfalls |
| 204 | +STOPSIGNAL SIGQUIT |
0 commit comments