Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
João Miguel Tabosa Vaz Marques Silva committed Jan 22, 2018
2 parents 52f1a17 + df434ac commit a6892ea
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 62 deletions.
106 changes: 58 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,93 +1,103 @@
FROM debian:jessie

LABEL maintainer "João Miguel <[email protected]>"
LABEL github "https://github.com/jmtvms/ngx_pagespeed"
LABEL dockerhub "https://hub.docker.com/r/jmtvms/ngx_pagespeed/"
LABEL repository="https://github.com/jmtvms/ngx_pagespeed.git"
LABEL bugs="https://github.com/jmtvms/ngx_pagespeed/issues"
LABEL github="https://github.com/jmtvms/ngx_pagespeed"
LABEL version="1.0.0"

RUN apt-get -y update && apt-get install -y \
wget \
build-essential \
libpcre3-dev \
zlib1g-dev
wget \
build-essential \
libpcre3-dev \
zlib1g-dev

ENV NGINX_VERSION=1.11.12
ENV NPS_VERSION=1.11.33.5
ENV NPS_VERSION=1.11.33.4-beta
ENV PSOL_VERSION=1.11.33.4
ENV SUBS_VERSION=0.6.4
ENV OPENSSL_VERSION=1.1.0e

RUN useradd -r -s /usr/sbin/nologin nginx

RUN ["mkdir","/usr/nginx_source/"]
WORKDIR "/usr/nginx_source/"

# Preparing Nginx
RUN wget -O nginx.tar.gz http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
RUN wget -qO nginx.tar.gz http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
RUN tar -xvzf nginx.tar.gz

# Preparing ngx_http_substitutions_filter_module
RUN wget -O ngx_http_substitutions_filter_module.tar.gz https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/v$SUBS_VERSION.tar.gz
RUN wget -qO ngx_http_substitutions_filter_module.tar.gz https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/v$SUBS_VERSION.tar.gz
RUN tar -xzvf ngx_http_substitutions_filter_module.tar.gz

# Preparing OpenSSL
RUN wget -qO openssl.tar.gz https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
RUN tar -xvzf openssl.tar.gz
RUN ls

# Preparing PageSpeed
RUN wget -O ngpagespeed.tar.gz https://github.com/pagespeed/ngx_pagespeed/archive/latest-stable.tar.gz
RUN wget -O ngpagespeed.tar.gz https://github.com/apache/incubator-pagespeed-ngx/archive/v$NPS_VERSION.tar.gz
RUN tar -xvzf ngpagespeed.tar.gz
WORKDIR "/usr/nginx_source/ngx_pagespeed-latest-stable/"
WORKDIR "/usr/nginx_source/incubator-pagespeed-ngx-$NPS_VERSION/"
RUN wget https://dl.google.com/dl/page-speed/psol/$PSOL_VERSION.tar.gz
RUN tar -xzvf $PSOL_VERSION.tar.gz

# Building Nginx
WORKDIR "/usr/nginx_source/nginx-$NGINX_VERSION/"

RUN ./configure \
--add-module=/usr/nginx_source/ngx_pagespeed-latest-stable \
--add-module=/usr/nginx_source/ngx_http_substitutions_filter_module-$SUBS_VERSION
--add-module=/usr/nginx_source/incubator-pagespeed-ngx-$NPS_VERSION \
--add-module=/usr/nginx_source/ngx_http_substitutions_filter_module-$SUBS_VERSION \
--with-openssl=/usr/nginx_source/openssl-$OPENSSL_VERSION \
--with-http_ssl_module \
--user=nginx \
--group=nginx \
--prefix=/opt/nginx \
--sbin-path=/opt/nginx/nginx \
--pid-path=/var/nginx/nginx.pid \
--error-log-path=/var/nginx/logs/error.log \
--http-log-path=/var/nginx/logs/access.log \
--conf-path=/opt/nginx/conf/nginx.conf


RUN make
RUN make install

RUN rm -rf /usr/nginx_source
RUN rm -rfd /usr/nginx_source

RUN apt-get purge -y \
wget \
build-essential \
libpcre3-dev \
zlib1g-dev \
&& apt-get autoremove -y


wget \
build-essential \
libpcre3-dev \
zlib1g-dev \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

ENV NGX_LOGLEVEL=debug
ENV NGX_UPSTREAM_NAME=www.google.com
ENV NGX_UPSTREAM_SERVER=www.google.com:80

ENV NPS_ENABLED=on
ENV NPS_LOWERCASEHTMLNAMES=on
ENV NPS_ENABLEFILTERS=rewrite_javascript,move_css_to_head,rewrite_css,combine_css,combine_javascript,collapse_whitespace,dedup_inlined_images,elide_attributes
ENV NPS_RESPECTVARY off
ENV NPS_DISABLEREWRITEONNOTRANSFORM on
ENV NPS_MODIFYCACHINGHEADERS on
ENV NPS_XHEADERVALUE "Powered By jmtvms/ngx_pagespeed"

COPY content/nginx.conf /usr/local/nginx/conf/
COPY content/robots.txt /usr/local/nginx/html/
COPY content/nginx.conf /opt/nginx/conf/
COPY content/robots.txt /opt/nginx/html/

# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /usr/local/nginx/logs/access.log
RUN ln -sf /dev/stderr /usr/local/nginx/logs/error.log

WORKDIR /usr/local/nginx/sbin/

ENTRYPOINT \
sed -i 's/%%NGX_LOGLEVEL%%/'"$NGX_LOGLEVEL"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NGX_UPSTREAM_NAME%%/'"$NGX_UPSTREAM_NAME"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NGX_UPSTREAM_SERVER%%/'"$NGX_UPSTREAM_SERVER"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NPS_ENABLED%%/'"$NPS_ENABLED"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NPS_LOWERCASEHTMLNAMES%%/'"$NPS_LOWERCASEHTMLNAMES"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NPS_ENABLEFILTERS%%/'"$NPS_ENABLEFILTERS"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NPS_RESPECTVARY%%/'"$NPS_RESPECTVARY"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NPS_DISABLEREWRITEONNOTRANSFORM%%/'"$NPS_DISABLEREWRITEONNOTRANSFORM"'/g' /usr/local/nginx/conf/nginx.conf && \
sed -i 's/%%NPS_MODIFYCACHINGHEADERS%%/'"$NPS_MODIFYCACHINGHEADERS"'/g' /usr/local/nginx/conf/nginx.conf && \
#cat /usr/local/nginx/conf/nginx.conf && \
/usr/local/nginx/sbin/./nginx -g 'daemon off;';

CMD [""]
RUN ln -sf /dev/stdout /var/nginx/logs/access.log
RUN ln -sf /dev/stderr /var/nginx/logs/error.log

WORKDIR /opt/nginx/
COPY start.sh ./
RUN chmod +x start.sh

ENTRYPOINT ["./start.sh"]
CMD ["-g", "'daemon off;'"]

EXPOSE 80
EXPOSE 443

VOLUME ["/opt/nginx/conf/"]
VOLUME ["/opt/nginx/html/"]
VOLUME ["/var/nginx/logs/"]
24 changes: 10 additions & 14 deletions content/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

#user nobody;
worker_processes 1;
user nginx;
worker_processes auto;

error_log logs/error.log %%NGX_LOGLEVEL%%;

pid logs/nginx.pid;
error_log /var/nginx/logs/error.log %%NGX_LOGLEVEL%%;

events {
worker_connections 1024;
Expand All @@ -18,7 +16,7 @@ http {
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log logs/access.log main;
access_log /var/nginx/logs/access.log main;

sendfile on;
#tcp_nopush on;
Expand All @@ -39,16 +37,14 @@ http {

pagespeed %%NPS_ENABLED%%;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
pagespeed LowercaseHtmlNames %%NPS_LOWERCASEHTMLNAMES%%;
pagespeed EnableFilters %%NPS_ENABLEFILTERS%%;
pagespeed RespectVary %%NPS_RESPECTVARY%%;
pagespeed DisableRewriteOnNoTransform %%NPS_DISABLEREWRITEONNOTRANSFORM%%;
pagespeed ModifyCachingHeaders %%NPS_MODIFYCACHINGHEADERS%%;
pagespeed XHeaderValue "%%NPS_XHEADERVALUE%%";
pagespeed LowercaseHtmlNames on;
pagespeed EnableFilters rewrite_javascript,move_css_to_head,rewrite_css,combine_css,combine_javascript,collapse_whitespace,dedup_inlined_images,elide_attributes;
pagespeed RespectVary off;
pagespeed DisableRewriteOnNoTransform on;
pagespeed ModifyCachingHeaders on;
pagespeed XHeaderValue "Powered By jmtvms/ngx_pagespeed";
#charset koi8-r;

access_log logs/host.access.log main;

location / {
subs_filter %%NGX_UPSTREAM_NAME%% $host;
proxy_pass http://%%NGX_UPSTREAM_NAME%%$uri$is_args$args;
Expand Down
8 changes: 8 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

sed -i 's/%%NGX_LOGLEVEL%%/'"$NGX_LOGLEVEL"'/g' /opt/nginx/conf/nginx.conf && \
sed -i 's/%%NGX_UPSTREAM_NAME%%/'"$NGX_UPSTREAM_NAME"'/g' /opt/nginx/conf/nginx.conf && \
sed -i 's/%%NGX_UPSTREAM_SERVER%%/'"$NGX_UPSTREAM_SERVER"'/g' /opt/nginx/conf/nginx.conf && \
sed -i 's/%%NPS_ENABLED%%/'"$NPS_ENABLED"'/g' /opt/nginx/conf/nginx.conf && \

eval "/opt/nginx/./nginx $@"

0 comments on commit a6892ea

Please sign in to comment.