Refactor code for improved performance and readability
Browse files- Dockerfile +197 -0
- sh.sh +10 -0
Dockerfile
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Dockerfile - Ubuntu Jammy
|
2 |
+
# https://github.com/openresty/docker-openresty
|
3 |
+
|
4 |
+
ARG RESTY_IMAGE_BASE="ubuntu"
|
5 |
+
ARG RESTY_IMAGE_TAG="jammy"
|
6 |
+
|
7 |
+
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG}
|
8 |
+
|
9 |
+
LABEL maintainer="Evan Wies <[email protected]>"
|
10 |
+
|
11 |
+
# Docker Build Arguments
|
12 |
+
ARG RESTY_IMAGE_BASE="ubuntu"
|
13 |
+
ARG RESTY_IMAGE_TAG="jammy"
|
14 |
+
ARG RESTY_VERSION="1.25.3.1"
|
15 |
+
ARG RESTY_LUAROCKS_VERSION="3.9.2"
|
16 |
+
ARG RESTY_OPENSSL_VERSION="1.1.1w"
|
17 |
+
ARG RESTY_OPENSSL_PATCH_VERSION="1.1.1f"
|
18 |
+
ARG RESTY_OPENSSL_URL_BASE="https://www.openssl.org/source"
|
19 |
+
ARG RESTY_PCRE_VERSION="8.45"
|
20 |
+
ARG RESTY_PCRE_BUILD_OPTIONS="--enable-jit"
|
21 |
+
ARG RESTY_PCRE_SHA256="4e6ce03e0336e8b4a3d6c2b70b1c5e18590a5673a98186da90d4f33c23defc09"
|
22 |
+
ARG RESTY_J="1"
|
23 |
+
ARG RESTY_CONFIG_OPTIONS="\
|
24 |
+
--with-compat \
|
25 |
+
--with-file-aio \
|
26 |
+
--with-http_addition_module \
|
27 |
+
--with-http_auth_request_module \
|
28 |
+
--with-http_dav_module \
|
29 |
+
--with-http_flv_module \
|
30 |
+
--with-http_geoip_module=dynamic \
|
31 |
+
--with-http_gunzip_module \
|
32 |
+
--with-http_gzip_static_module \
|
33 |
+
--with-http_image_filter_module=dynamic \
|
34 |
+
--with-http_mp4_module \
|
35 |
+
--with-http_random_index_module \
|
36 |
+
--with-http_realip_module \
|
37 |
+
--with-http_secure_link_module \
|
38 |
+
--with-http_slice_module \
|
39 |
+
--with-http_ssl_module \
|
40 |
+
--with-http_stub_status_module \
|
41 |
+
--with-http_sub_module \
|
42 |
+
--with-http_v2_module \
|
43 |
+
--with-http_v3_module \
|
44 |
+
--with-http_xslt_module=dynamic \
|
45 |
+
--with-ipv6 \
|
46 |
+
--with-mail \
|
47 |
+
--with-mail_ssl_module \
|
48 |
+
--with-md5-asm \
|
49 |
+
--with-sha1-asm \
|
50 |
+
--with-stream \
|
51 |
+
--with-stream_ssl_module \
|
52 |
+
--with-threads \
|
53 |
+
"
|
54 |
+
ARG RESTY_CONFIG_OPTIONS_MORE=""
|
55 |
+
ARG RESTY_LUAJIT_OPTIONS="--with-luajit-xcflags='-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'"
|
56 |
+
ARG RESTY_PCRE_OPTIONS="--with-pcre-jit"
|
57 |
+
|
58 |
+
ARG RESTY_ADD_PACKAGE_BUILDDEPS=""
|
59 |
+
ARG RESTY_ADD_PACKAGE_RUNDEPS=""
|
60 |
+
ARG RESTY_EVAL_PRE_CONFIGURE=""
|
61 |
+
ARG RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE=""
|
62 |
+
ARG RESTY_EVAL_POST_MAKE=""
|
63 |
+
|
64 |
+
# These are not intended to be user-specified
|
65 |
+
ARG _RESTY_CONFIG_DEPS="--with-pcre \
|
66 |
+
--with-cc-opt='-DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' \
|
67 |
+
--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' \
|
68 |
+
"
|
69 |
+
|
70 |
+
LABEL resty_image_base="${RESTY_IMAGE_BASE}"
|
71 |
+
LABEL resty_image_tag="${RESTY_IMAGE_TAG}"
|
72 |
+
LABEL resty_version="${RESTY_VERSION}"
|
73 |
+
LABEL resty_luarocks_version="${RESTY_LUAROCKS_VERSION}"
|
74 |
+
LABEL resty_openssl_version="${RESTY_OPENSSL_VERSION}"
|
75 |
+
LABEL resty_openssl_patch_version="${RESTY_OPENSSL_PATCH_VERSION}"
|
76 |
+
LABEL resty_openssl_url_base="${RESTY_OPENSSL_URL_BASE}"
|
77 |
+
LABEL resty_pcre_version="${RESTY_PCRE_VERSION}"
|
78 |
+
LABEL resty_pcre_build_options="${RESTY_PCRE_BUILD_OPTIONS}"
|
79 |
+
LABEL resty_pcre_sha256="${RESTY_PCRE_SHA256}"
|
80 |
+
LABEL resty_config_options="${RESTY_CONFIG_OPTIONS}"
|
81 |
+
LABEL resty_config_options_more="${RESTY_CONFIG_OPTIONS_MORE}"
|
82 |
+
LABEL resty_config_deps="${_RESTY_CONFIG_DEPS}"
|
83 |
+
LABEL resty_add_package_builddeps="${RESTY_ADD_PACKAGE_BUILDDEPS}"
|
84 |
+
LABEL resty_add_package_rundeps="${RESTY_ADD_PACKAGE_RUNDEPS}"
|
85 |
+
LABEL resty_eval_pre_configure="${RESTY_EVAL_PRE_CONFIGURE}"
|
86 |
+
LABEL resty_eval_post_download_pre_configure="${RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE}"
|
87 |
+
LABEL resty_eval_post_make="${RESTY_EVAL_POST_MAKE}"
|
88 |
+
LABEL resty_luajit_options="${RESTY_LUAJIT_OPTIONS}"
|
89 |
+
LABEL resty_pcre_options="${RESTY_PCRE_OPTIONS}"
|
90 |
+
|
91 |
+
|
92 |
+
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
|
93 |
+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
94 |
+
build-essential \
|
95 |
+
ca-certificates \
|
96 |
+
curl \
|
97 |
+
gettext-base \
|
98 |
+
libgd-dev \
|
99 |
+
libgeoip-dev \
|
100 |
+
libncurses5-dev \
|
101 |
+
libperl-dev \
|
102 |
+
libreadline-dev \
|
103 |
+
libxslt1-dev \
|
104 |
+
make \
|
105 |
+
perl \
|
106 |
+
unzip \
|
107 |
+
wget \
|
108 |
+
zlib1g-dev \
|
109 |
+
${RESTY_ADD_PACKAGE_BUILDDEPS} \
|
110 |
+
${RESTY_ADD_PACKAGE_RUNDEPS} \
|
111 |
+
&& cd /tmp \
|
112 |
+
&& if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \
|
113 |
+
&& curl -fSL "${RESTY_OPENSSL_URL_BASE}/openssl-${RESTY_OPENSSL_VERSION}.tar.gz" -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
|
114 |
+
&& tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
|
115 |
+
&& cd openssl-${RESTY_OPENSSL_VERSION} \
|
116 |
+
&& if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.1" ] ; then \
|
117 |
+
echo 'patching OpenSSL 1.1.1 for OpenResty' \
|
118 |
+
&& curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \
|
119 |
+
fi \
|
120 |
+
&& if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.0" ] ; then \
|
121 |
+
echo 'patching OpenSSL 1.1.0 for OpenResty' \
|
122 |
+
&& curl -s https://raw.githubusercontent.com/openresty/openresty/ed328977028c3ec3033bc25873ee360056e247cd/patches/openssl-1.1.0j-parallel_build_fix.patch | patch -p1 \
|
123 |
+
&& curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \
|
124 |
+
fi \
|
125 |
+
&& ./config \
|
126 |
+
no-threads shared zlib -g \
|
127 |
+
enable-ssl3 enable-ssl3-method \
|
128 |
+
--prefix=/usr/local/openresty/openssl \
|
129 |
+
--libdir=lib \
|
130 |
+
-Wl,-rpath,/usr/local/openresty/openssl/lib \
|
131 |
+
&& make -j${RESTY_J} \
|
132 |
+
&& make -j${RESTY_J} install_sw \
|
133 |
+
&& cd /tmp \
|
134 |
+
&& curl -fSL https://downloads.sourceforge.net/project/pcre/pcre/${RESTY_PCRE_VERSION}/pcre-${RESTY_PCRE_VERSION}.tar.gz -o pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
135 |
+
&& echo "${RESTY_PCRE_SHA256} pcre-${RESTY_PCRE_VERSION}.tar.gz" | shasum -a 256 --check \
|
136 |
+
&& tar xzf pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
137 |
+
&& cd /tmp/pcre-${RESTY_PCRE_VERSION} \
|
138 |
+
&& ./configure \
|
139 |
+
--prefix=/usr/local/openresty/pcre \
|
140 |
+
--disable-cpp \
|
141 |
+
--enable-utf \
|
142 |
+
--enable-unicode-properties \
|
143 |
+
${RESTY_PCRE_BUILD_OPTIONS} \
|
144 |
+
&& make -j${RESTY_J} \
|
145 |
+
&& make -j${RESTY_J} install \
|
146 |
+
&& cd /tmp \
|
147 |
+
&& curl -fSL https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz -o openresty-${RESTY_VERSION}.tar.gz \
|
148 |
+
&& tar xzf openresty-${RESTY_VERSION}.tar.gz \
|
149 |
+
&& cd /tmp/openresty-${RESTY_VERSION} \
|
150 |
+
&& if [ -n "${RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_POST_DOWNLOAD_PRE_CONFIGURE}); fi \
|
151 |
+
&& eval ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} ${RESTY_LUAJIT_OPTIONS} ${RESTY_PCRE_OPTIONS} \
|
152 |
+
&& make -j${RESTY_J} \
|
153 |
+
&& make -j${RESTY_J} install \
|
154 |
+
&& cd /tmp \
|
155 |
+
&& rm -rf \
|
156 |
+
openssl-${RESTY_OPENSSL_VERSION}.tar.gz openssl-${RESTY_OPENSSL_VERSION} \
|
157 |
+
pcre-${RESTY_PCRE_VERSION}.tar.gz pcre-${RESTY_PCRE_VERSION} \
|
158 |
+
openresty-${RESTY_VERSION}.tar.gz openresty-${RESTY_VERSION} \
|
159 |
+
&& curl -fSL https://luarocks.github.io/luarocks/releases/luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz -o luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
|
160 |
+
&& tar xzf luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
|
161 |
+
&& cd luarocks-${RESTY_LUAROCKS_VERSION} \
|
162 |
+
&& ./configure \
|
163 |
+
--prefix=/usr/local/openresty/luajit \
|
164 |
+
--with-lua=/usr/local/openresty/luajit \
|
165 |
+
--lua-suffix=jit-2.1.0-beta3 \
|
166 |
+
--with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1 \
|
167 |
+
&& make build \
|
168 |
+
&& make install \
|
169 |
+
&& cd /tmp \
|
170 |
+
&& if [ -n "${RESTY_EVAL_POST_MAKE}" ]; then eval $(echo ${RESTY_EVAL_POST_MAKE}); fi \
|
171 |
+
&& rm -rf luarocks-${RESTY_LUAROCKS_VERSION} luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
|
172 |
+
&& if [ -n "${RESTY_ADD_PACKAGE_BUILDDEPS}" ]; then DEBIAN_FRONTEND=noninteractive apt-get remove -y --purge ${RESTY_ADD_PACKAGE_BUILDDEPS} ; fi \
|
173 |
+
&& DEBIAN_FRONTEND=noninteractive apt-get autoremove -y \
|
174 |
+
&& mkdir -p /var/run/openresty \
|
175 |
+
&& ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \
|
176 |
+
&& ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log
|
177 |
+
|
178 |
+
# Add additional binaries into PATH for convenience
|
179 |
+
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
|
180 |
+
|
181 |
+
# Add LuaRocks paths
|
182 |
+
# If OpenResty changes, these may need updating:
|
183 |
+
# /usr/local/openresty/bin/resty -e 'print(package.path)'
|
184 |
+
# /usr/local/openresty/bin/resty -e 'print(package.cpath)'
|
185 |
+
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.0-beta3/?.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"
|
186 |
+
|
187 |
+
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"
|
188 |
+
|
189 |
+
# Copy nginx configuration files
|
190 |
+
COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
|
191 |
+
COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf
|
192 |
+
|
193 |
+
CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"]
|
194 |
+
|
195 |
+
# Use SIGQUIT instead of default SIGTERM to cleanly drain requests
|
196 |
+
# See https://github.com/openresty/docker-openresty/blob/master/README.md#tips--pitfalls
|
197 |
+
STOPSIGNAL SIGQUIT
|
sh.sh
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
apt install wget unzip curl zlib1g-dev g++ make libpcre3-dev perl build-essential curl git -y
|
2 |
+
git clone https://mirror.ghproxy.com/https://github.com/Tongsuo-Project/Tongsuo.git
|
3 |
+
|
4 |
+
wget https://mirror.ghproxy.com/https://github.com/openresty/openresty/releases/download/v1.25.3.1/openresty-1.25.3.1.tar.gz
|
5 |
+
tar -xzvf openresty-1.25.3.1.tar.gz
|
6 |
+
cd openresty-1.25.3.1/
|
7 |
+
./configure --prefix=/usr/local/openresty --with-http_stub_status_module --with-stream --with-http_ssl_module --with-stream_ssl_module --with-openssl=/root/Tongsuo
|
8 |
+
make -j3
|
9 |
+
sudo make install
|
10 |
+
|