Dockerfile 657 B

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