利用dockerfile 安装一个nginx-1.14.1

FROM  docker.io/centos

MAINTAINER jim [email protected]
ENV TZ "Asia/Shanghai"
#ENV TERM xterm

RUN mkdir -p /etc/yum.repos.d/bak && cd /etc/yum.repos.d/ && mv /etc/yum.repos.d/*.repo bak/
#把当前目录下的localhost.repo追加到镜像的/etc/yum.repo.d/目录下
ADD localhost.repo /etc/yum.repos.d/docker.repo
#执行的命令
RUN yum clean all

RUN yum makecache

RUN yum repolist

RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
RUN yum install -y wget file vim* gcc gcc-c++ make openssl-devel lrzsz patch unzip libuuid-devel libunwind libunwind-level cmake  net-tools make pcre-devel zlib-devel
ADD pcre-8.42.tar.gz /usr/local/src
ADD nginx-1.14.1.tar.gz  /usr/local/src
ADD zlib-1.2.11.tar.gz /usr/local/src
ADD openssl-1.1.0c.tar.gz /usr/local/src
ADD libunwind-1.2.tar.gz /usr/local/src
ADD gperftools-2.7.tar.gz /usr/local/src
ADD incubator-pagespeed-ngx-1.13.35.2-stable.zip /usr/local/src
ADD posl-1.13.35.2-x64.tar.gz /usr/local/src
ADD nginx_upstream_check_module-master.zip /usr/local/src
ADD nginx.conf /usr/local/src
ADD localhost.conf /usr/local/src

WORKDIR /usr/local/src/pcre-8.42
RUN ./configure --prefix=/usr/local/pcre && make && make install

WORKDIR /usr/local/src/zlib-1.2.11
RUN ./configure --prefix=/usr/local/zlib && make && make install

WORKDIR /usr/local/src/openssl-1.1.0c
RUN ./config --prefix=/usr/local/openssl && make && make install

RUN ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
RUN ln -s /usr/local/openssl/include/openssl /usr/include/openssl
RUN ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

RUN echo "/usr/local/lib" >> /etc/ld.so.conf
RUN echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
RUN /sbin/ldconfig

WORKDIR /usr/local/src/libunwind-1.2
RUN ./configure --prefix=/usr/local/libunwind && make && make install

WORKDIR /usr/local/src/gperftools-2.7
RUN ./configure --prefix=/usr/local/gperftools --enable-libunwind --enable-frame-pointers --enable-emergency-malloc && make && make install
RUN ln -s /usr/local/gperftools/lib/* /usr/local/lib
RUN mkdir -p /tmp/tcmalloc
RUN chmod 0777 /tmp/tcmalloc/
RUN /sbin/ldconfig

WORKDIR /usr/local/src/

RUN unzip incubator-pagespeed-ngx-1.13.35.2-stable.zip
RUN unzip nginx_upstream_check_module-master.zip
RUN cp -frp psol incubator-pagespeed-ngx-1.13.35.2-stable/psol

RUN find incubator-pagespeed-ngx-1.13.35.2-stable  -type d -exec chmod +rx {} \;
RUN find incubator-pagespeed-ngx-1.13.35.2-stable -type f -exec chmod +r {} \;

WORKDIR /usr/local/src/nginx-1.14.1
RUN patch -p1 < ../nginx_upstream_check_module-master/check_1.14.0+.patch

WORKDIR /usr/local/src/nginx-1.14.1/


RUN useradd -s /sbin/nologin -M www
RUN ./configure --prefix=/usr/local/nginx --user=www --group=www --pid-path=/usr/local/nginx/nginx.pid --lock-path=/usr/local/nginx/lock/nginx.lock --with-stream --with-stream_ssl_modul
e --with-http_realip_module --with-http_auth_request_module --with-http_ssl_module --with-google_perftools_module --with-file-aio  --with-http_dav_module --with-http_flv_module --with-h
ttp_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-pcre=/usr/local/src/pcre-8.42 --with-pcre=/usr/local/src/pcre-8
.42 --with-openssl=/usr/local/src/openssl-1.1.0c  --with-zlib=/usr/local/src/zlib-1.2.11 --with-debug  --with-http_stub_status_module --add-module=/usr/local/src/nginx_upstream_check_mo
dule-master --add-module=/usr/local/src/incubator-pagespeed-ngx-1.13.35.2-stable --http-client-body-temp-path=/usr/local/nginx/client --http-proxy-temp-path=/usr/local/nginx/proxy --htt
p-fastcgi-temp-path=/usr/local/nginx/fastcgi --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/local/nginx/scgi && make && make install

RUN mkdir -p /usr/local/nginx/{lock,proxy,client,fastcgi,uwsgi,scgi,logs/localhost}
RUN ln -s /usr/local/nginx/sbin/* /usr/local/sbin/

RUN mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
WORKDIR /usr/local/src/
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
RUN mkdir -p /usr/local/nginx/conf/vhosts
COPY localhost.conf /usr/local/nginx/conf/vhosts/localhost.conf
RUN cd /usr/local/src && rm -rf *
RUN yum clean all
RUN rm -rf /var/cache/yum

EXPOSE 80
WORKDIR /
RUN nginx
CMD ["nginx", "-g", "daemon off;"]

  

你可能感兴趣的:(利用dockerfile 安装一个nginx-1.14.1)