gpt4 book ai didi

docker - 我在哪里可以找到 docker 的 nginx(稳定)?

转载 作者:行者123 更新时间:2023-12-02 21:10:14 31 4
gpt4 key购买 nike

我正在尝试制作一个包含 Nginx stable 最新使用 vts 模块编译的 dockerfile .... 我遇到了一个大问题,当我放入将下载的 docker 文件时我找不到一些汽车链接安装最新的稳定 nginx 我只能指定一个像 1.14.2 这样的版本有没有办法我可以修改我的 dockerfile 让它总是下载最新的,而不仅仅是一个版本?

这是我的 docker 文件

FROM debian:stretch-slim




RUN apt-get update && \
apt-get install -y git wget libreadline-dev libncurses5-dev libpcre3- dev libssl-dev perl make build-essential zlib1g-dev && \
cd /tmp/ && \
wget http://nginx.org/download/nginx-1.14.2.tar.gz && \
git clone git://github.com/vozlt/nginx-module-vts.git && \
tar zxvf nginx-1.14.2.tar.gz && \
rm -f nginx-1.14.2.tar.gz && \
cd nginx-1.14.2 && \
./configure --prefix=/tmp/nginx-1.14.2 --sbin-path=/usr/sbin/nginx -- modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock --http-client-body-temp- path=/var/cache/nginx/client_temp --http-proxy-temp- path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi- temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp- path=/var/cache/nginx/scgi_temp \
--user=nginx --group=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_gunzip_module --with-http_gzip_static_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-mail --with-mail_ssl_module --with-stream \
--with-stream_realip_module --with-stream_ssl_module --with- stream_ssl_preread_module \
--with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx- 1.14.2/debian/debuild-base/nginx-1.14.2=. -specs=/usr/share/dpkg/no-pie- compile.specs -fstack-protector-strong -Wformat -Werror=format-security - Wp,-D_FORTIFY_SOURCE=2 -fPIC' \
--with-ld-opt='-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro - Wl,-z,now -Wl,--as-needed -pie' \
--add-module=/tmp/nginx-module-vts && \
make && make install && \
cp -f objs/nginx /usr/sbin/nginx && \
apt-get clean && rm -rf /var/lib/apt/lists/*

CMD ["nginx", "-g", "daemon off;"]

最佳答案

如果您正在寻找一种简单的方法来在从源代码编译 nginx 期间继续使用稳定版本,因为它没有一个直接的 url afaik,那么您可以传递 build argument像这样到您的 Dockerfile 中:

...
ARG NGINX_STABLE_VERSION
RUN wget http://nginx.org/download/nginx-${NGINX_STABLE_VERSION}.tar.gz
...

并运行如下构建命令以根据传递的参数继续下载 nginx 版本:
docker build --build-arg NGINX_STABLE_VERSION=1.14.2 .

但是,如果您正在寻找如何通过自定义模块继续使用 nginx 的官方 docker 镜像 - 假设您使用的所有自定义模块都支持动态模块功能,例如 vts 模块 - 然后你可以使用 multi-stage builds并利用 nginx dynamic modules特征。

根据 nginx-module-vts changelog支持将模块编译为动态模块,因此您可以进行多阶段构建,使用您想要的模块编译 nginx,然后将生成的文件复制到具有相同版本的 nginx 镜像以使其工作。

Nginx 稳定镜像可以在 here 找到标记为 stable单词。

您现在需要做的就是修改 Dockerfile 并使其使用动态模块的方式,然后添加另一个阶段以使用从第一阶段生成的新模块的稳定镜像,您可以在构建期间添加一个参数,例如:
...
ARG NGINX_STABLE_VERSION
RUN wget http://nginx.org/download/nginx-${NGINX_STABLE_VERSION}.tar.gz
...

并像这样运行构建:
docker build --build-arg NGINX_STABLE_VERSION=1.14.2 .

更新:

Nginx 没有提供一个链接,您可以每次都使用它来获取稳定版本,因此您可以像下面这样解析下载页面的 html,以不断获取稳定版本的最新下载链接:

We rely on the HTML page which is not the most robust solution on the long term.


echo "http://nginx.org$(curl -s http://nginx.org/en/download.html | grep -oP 'Stable version.*?\K(/download/.*?tar.gz)')"

输出:
http://nginx.org/download/nginx-1.14.2.tar.gz

在您的 Dockerfile 中,它可以是这样的:

Make sure that you have curl installed


RUN curl "http://nginx.org$(curl -s http://nginx.org/en/download.html | grep -oP 'Stable version.*?\K(/download/.*?tar.gz)')" --output nginx.tar.gz

关于docker - 我在哪里可以找到 docker 的 nginx(稳定)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55077706/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com