nginx打包镜像的Dockerfile

目录结构

nginx/
   - nginx-1.26.3/
         - src/
         - auto/
         - nginx-module-vts/
         - html/
         - conf/
         - man/
         - configure
         - CHANGES
         - README
   - Dockerfile
   - nginx-1.26.3.tar.gz
   - nginx-module-vts-0.2.0.tar.gz

如果需要nginx-module-vts-0.2.0.tar.gz,解压 到 nginx-1.26.3文件夹中

Dockerfile:

FROM rockylinux/rockylinux:8                 

ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN yum -y install pcre-devel zlib-devel gcc gcc-c++ make openssl openssl-devel 

RUN useradd -M -s /sbin/nologin nginx    
COPY nginx-1.26.3/ /usr/local/nginx/  
WORKDIR /usr/local/nginx     
RUN ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module --with-stream --with-stream_ssl_module --add-module=/usr/local/nginx/nginx-module-vts && make && make install


ENV PATH /usr/local/nginx/sbin:$PATH  


RUN chmod 777 -R /usr/local/nginx/html/  
EXPOSE 80                               
EXPOSE 443                             
VOLUME [ "/usr/local/nginx/html/" ]
VOLUME [ "/data/files/" ]
VOLUME [ "/ocs-kdb/upload/" ]
VOLUME [ "/ocs-livechat/uploadfile/" ]  
ENTRYPOINT [ "/usr/local/nginx/sbin/nginx","-c", "/usr/local/nginx/conf/nginx.conf", "-g", "daemon off;" ]

打包镜像build,注意后面的.代表当前目录

docker build -t nginx:1.26.3 .
评论