Dockerfile
# 使用官方的 Alpine 基础镜像 FROM alpine:latest ARG VERSION=1.24.0 # 更新包列表并安装必要的依赖 RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN apk update && \ apk add --no-cache build-base libgcc zlib-dev pcre-dev openssl-dev git # 创建临时目录用于编译 Nginx RUN mkdir /tmp/nginx-src WORKDIR /tmp/nginx-src # 下载 Nginx 源码 RUN wget https://nginx.org/download/nginx-${VERSION}.tar.gz RUN tar -xzvf nginx-${VERSION}.tar.gz WORKDIR /tmp/nginx-src/nginx-${VERSION} # 下载 headers-more 模块 RUN git clone https://github.com/openresty/headers-more-nginx-module.git # 编译 Nginx RUN ./configure --prefix=/etc/nginx --add-module=/tmp/nginx-src/nginx-${VERSION}/headers-more-nginx-module RUN make RUN make install # 清理编译环境 RUN rm -rf /tmp/nginx-src # 复制自定义的 Nginx 配置文件到容器中 COPY nginx.conf /etc/nginx/nginx.conf # 启动 Nginx CMD ["nginx", "-g", "daemon off;"]
标签:tmp,RUN,Nginx,module,nginx,VERSION,headers From: https://www.cnblogs.com/navysummer/p/18421298