FROM alpine AS build
ARG VERSION=openresty-1.21.4.1
ARG ADD_MODULE="\
https://github.com/openresty/array-var-nginx-module/archive/refs/tags/v0.05.tar.gz \
https://github.com/openresty/echo-nginx-module/archive/refs/tags/v0.63.tar.gz \
https://github.com/openresty/encrypted-session-nginx-module/archive/refs/tags/v0.09.tar.gz \
https://github.com/calio/form-input-nginx-module/archive/refs/tags/v0.12.tar.gz \
https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.34.tar.gz \
https://github.com/openresty/memc-nginx-module/archive/refs/tags/v0.19.tar.gz \
https://github.com/FRiCKLE/ngx_coolkit/archive/refs/tags/0.2.tar.gz \
https://github.com/vision5/ngx_devel_kit/archive/refs/tags/v0.3.2.tar.gz \
https://github.com/openresty/lua-nginx-module/archive/refs/tags/v0.10.22.tar.gz \
https://github.com/openresty/lua-upstream-nginx-module/archive/refs/tags/v0.07.tar.gz \
https://github.com/openresty/stream-lua-nginx-module/archive/refs/tags/v0.0.11.tar.gz \
https://github.com/openresty/rds-csv-nginx-module/archive/refs/tags/v0.09.tar.gz \
https://github.com/openresty/rds-json-nginx-module/archive/refs/tags/v0.15.tar.gz \
https://github.com/openresty/redis2-nginx-module/archive/refs/tags/v0.15.tar.gz \
https://github.com/openresty/set-misc-nginx-module/archive/refs/tags/v0.33.tar.gz \
https://github.com/openresty/srcache-nginx-module/archive/refs/tags/v0.32.tar.gz \
https://github.com/openresty/xss-nginx-module/archive/refs/tags/v0.06.tar.gz \
"
WORKDIR /opt
RUN if [ -f /etc/apk/repositories ];then sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories; fi && \
if [ -f /etc/apt/sources.list ];then sed -ri 's/(deb|security).debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list; fi && \
if [ ! -e /etc/nsswitch.conf ];then echo 'hosts: files dns myhostname' > /etc/nsswitch.conf; fi && \
apk add --no-cache --virtual .build-deps \
gcc \
libc-dev \
make \
openssl-dev \
pcre-dev \
libxml2-dev libxslt-dev \
libjpeg-turbo-static libpng-static libwebp-static
zlib-dev \
openssl-libs-static zlib-static \
linux-headers \
libxslt-dev \
gd-dev \
geoip-dev \
perl-dev \
libedit-dev \
bash \
alpine-sdk \
findutils
RUN for m in ${ADD_MODULE};do \
wget $m -O-| tar zxf -; \
done && \
wget https://openresty.org/download/${VERSION}.tar.gz && tar zxf ${VERSION}.tar.gz && \
rm -f ${VERSION}.tar.gz
RUN cd ${VERSION} && \
./configure \
$(ls -l ../ | awk -vN=${VERSION} '$NF!=N&&$1~/^d/&&$NF~/.+?\.[0-9]+$/{printf " --add-module=../%s ",$NF}') \
--prefix=/usr/local/openresty/nginx \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_geoip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
#加不上 --with-http_image_filter_module \
--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 \
--with-mail \
--with-mail_ssl_module \
--with-pcre \
--with-pcre-jit \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-cc-opt='-static -s' \
--with-ld-opt=-static
RUN cd ${VERSION} && \
mkdir /install_root && \
make
上面是我的步骤,但是 make 的时候 ld 报错,最终需求是如果不是静态编译,那把整个目录拷贝到另一个机器上也可以运行,信创的适配要求大概这样。
nginx 静态编译没问题,但是 openresty module 挺多的,有没有老哥知道怎么尽可能的静态编译
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.