Skip to content

Instantly share code, notes, and snippets.

@rzani
Created Jan 25, 2017
Embed
What would you like to do?
Nginx + Pagespeed
FROM debian:jessie
MAINTAINER Rodrigo Zani <rodrigo.zhs@gmail.com>
ENV NGINX_VERSION 1.11.9
ENV NPS_VERSION 1.11.33.4
RUN apt-get update && \
apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip make wget libssl-dev && \
rm -rf /var/lib/apt/lists/*
# Downloading Pagespeed
RUN cd /usr/src && \
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}-beta.zip && \
unzip v${NPS_VERSION}-beta.zip && \
cd /usr/src/ngx_pagespeed-${NPS_VERSION}-beta/ && \
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz && \
tar -xzvf ${NPS_VERSION}.tar.gz
# Downloading NGINX
RUN cd /usr/src && \
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
tar -xvzf nginx-${NGINX_VERSION}.tar.gz && \
cd /usr/src/nginx-${NGINX_VERSION}/ && \
./configure --add-module=/usr/src/ngx_pagespeed-${NPS_VERSION}-beta \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module && \
make && \
make install
# Clean up
RUN mkdir -p /var/pagespeed/cache && \
mkdir -p /var/cache/nginx && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
RUN useradd --no-create-home nginx
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment