123456789101112131415161718192021 |
- # 使用官方Nginx镜像作为基础
- FROM nginx:1.27-alpine AS builder
- RUN apk add --no-cache build-base linux-headers pcre-dev zlib-dev && \
- wget http://nginx.org/download/nginx-1.27.3.tar.gz && \
- tar -zxvf nginx-1.27.3.tar.gz && \
- cd nginx-1.27.3 && \
- ./configure \
- --prefix=/etc/nginx \
- --with-http_gzip_module \
- --with-http_gzip_static_module \
- --with-http_gunzip_module && \
- make && make install
- FROM nginx:1.27-alpine
- COPY --from=builder /usr/sbin/nginx /usr/sbin/nginx
- # 验证模块
- RUN nginx -V 2>&1 | grep -E 'gzip|gunzip'
- # 复制 nginx 配置文件
- COPY ./nginx.conf /etc/nginx/nginx.conf
|