Created
June 25, 2016 22:13
-
-
Save LukeFlynn/aa8bbf69ef89c7caf61a6440cdd00dd3 to your computer and use it in GitHub Desktop.
Nginx 1.10.1 w/ Pagespeed. Built on RHEL 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM centos:centos7 | |
WORKDIR /tmp | |
# Install prerequisites for Nginx compile | |
RUN yum install -y \ | |
wget \ | |
tar \ | |
openssl-devel \ | |
gcc \ | |
gcc-c++ \ | |
make \ | |
zlib-devel \ | |
pcre-devel \ | |
gd-devel \ | |
git | |
# Download Nginx and Nginx modules source | |
RUN mkdir -p /usr/local/src/nginx && \ | |
wget http://nginx.org/download/nginx-1.10.1.tar.gz -O nginx.tar.gz && \ | |
tar -xzvf nginx.tar.gz -C /usr/local/src/nginx &&\ | |
git clone https://github.com/pagespeed/ngx_pagespeed /usr/local/src/nginx/ngx_pagespeed && \ | |
wget https://dl.google.com/dl/page-speed/psol/1.11.33.2.tar.gz -O psol.tar.gz && \ | |
tar -xzvf psol.tar.gz -C /usr/local/src/nginx/ngx_pagespeed | |
# Build Nginx | |
WORKDIR /usr/local/src/nginx/nginx-1.10.1 | |
RUN ./configure \ | |
--user=nginx \ | |
--with-debug \ | |
--group=nginx \ | |
--prefix=/usr/share/nginx \ | |
--sbin-path=/usr/sbin/nginx \ | |
--conf-path=/etc/nginx/nginx.conf \ | |
--pid-path=/run/nginx.pid \ | |
--lock-path=/run/lock/subsys/nginx \ | |
--error-log-path=/var/log/nginx/error.log \ | |
--http-log-path=/var/log/nginx/access.log \ | |
--with-http_gzip_static_module \ | |
--with-http_stub_status_module \ | |
--with-http_ssl_module \ | |
--with-pcre \ | |
--with-http_image_filter_module \ | |
--with-file-aio \ | |
--with-ipv6 \ | |
--with-http_dav_module \ | |
--with-http_v2_module \ | |
--with-http_flv_module \ | |
--with-http_mp4_module \ | |
--with-http_gunzip_module \ | |
--add-module=/usr/local/src/nginx/ngx_pagespeed && \ | |
make && \ | |
make install | |
WORKDIR /usr/local/src/nginx | |
# Add nginx user | |
RUN adduser -c "Nginx user" nginx && \ | |
setcap cap_net_bind_service=ep /usr/sbin/nginx | |
RUN touch /run/nginx.pid | |
RUN rm -rf /etc/nginx/nginx.conf | |
ADD nginx.conf /etc/nginx | |
RUN mkdir /var/pagespeed_cache | |
RUN chown nginx:nginx /etc/nginx /etc/nginx/nginx.conf /var/log/nginx /usr/share/nginx /run/nginx.pid /var/pagespeed_cache | |
# Cleanup after Nginx build | |
RUN yum remove -y \ | |
wget \ | |
tar \ | |
gcc \ | |
gcc-c++ \ | |
make \ | |
git && \ | |
yum autoremove -y && \ | |
rm -rf /tmp/* | |
# PORTS | |
EXPOSE 80 | |
EXPOSE 443 | |
USER nginx | |
CMD ["/usr/sbin/nginx", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment