千家信息网

Dockerfile制作nginx镜像

发表于:2025-02-04 作者:千家信息网编辑
千家信息网最后更新 2025年02月04日,nginx版本为1.16.1,基础镜像为alpine-linux,镜像最终大小为25.7MFROM alpine:latestENV ng_config /usr/local/nginx-1.16.1
千家信息网最后更新 2025年02月04日Dockerfile制作nginx镜像

nginx版本为1.16.1,基础镜像为alpine-linux,镜像最终大小为25.7M

FROM alpine:latestENV ng_config /usr/local/nginx-1.16.1ADD nginx-1.16.1.tar.gz /usr/local/RUN CONFIG="\--prefix=/usr/local/nginx \--user=nginx \--group=nginx \--with-http_ssl_module \--with-http_gzip_static_module \--with-http_image_filter_module \--with-http_stub_status_module \" \&& addgroup -S nginx \&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \&& apk add --no-cache --virtual .build-deps \gcc g++ pcre pcre-dev expat-dev perl zlib-dev libxml2-dev make openssl openssl-dev bzip2-dev gd gd-dev \&& rm -rf /var/cache/apk/* \&& cd $ng_config \&& ./configure $CONFIG \&& sed -ri "s/-Werror//" $ng_config/objs/Makefile \&& make \&& make install \#######################清除虚包#########################&& runDeps="$( \scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \| tr ',' '\n' \| sort -u \| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \)" \&& apk add --no-cache $runDeps \&& apk del  .build-deps \&& rm -rf $ng_config########################################################expose 80 443WORKDIR /usr/local/nginx/ENTRYPOINT [ "./sbin/nginx" ,"-g" ,"daemon off;"]

0