Skip to content

Commit

Permalink
Switch to building from offical docker
Browse files Browse the repository at this point in the history
  • Loading branch information
sachk committed Aug 27, 2018
1 parent 03686e4 commit 8d5c24b
Showing 1 changed file with 35 additions and 100 deletions.
135 changes: 35 additions & 100 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,112 +1,47 @@
FROM alpine:3.8 as buider

# Inspired by wunderkraut/alpine-nginx-pagespeed (aka ilari/alpine-nginx-pagespeed:latest) with some extra modules.
FROM alpine:3.4 as buider

ENV NGINX_VERSION=1.15.2

ENV PAGESPEED_VERSION=1.13.35.2-stable

ENV PS_NGX_EXTRA_FLAGS="--with-ipv6 \
--prefix=/var/lib/nginx \
--sbin-path=/usr/sbin \
--modules-path=/usr/lib/nginx \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-file-aio \
--with-http_v2_module \
--without-http_autoindex_module \
--without-http_browser_module \
--without-http_geo_module \
--without-http_map_module \
--without-http_memcached_module \
--without-http_userid_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--without-http_split_clients_module \
--without-http_scgi_module \
--without-http_referer_module \
--without-http_upstream_ip_hash_module \
--prefix=/etc/nginx \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid"

RUN apk --no-cache add \
ca-certificates \
libuuid \
apr \
apr-util \
libjpeg-turbo \
icu \
icu-libs \
openssl \
pcre \
zlib \
apache2-dev \
apr-dev \
apr-util-dev \
build-base \
curl \
icu-dev \
libjpeg-turbo-dev \
linux-headers \
gperf \
openssl-dev \
pcre-dev \
python \
zlib-dev \
git
RUN apk --no-cache --update add \
ca-certificates \
libuuid \
apr \
apr-util \
libjpeg-turbo \
icu \
icu-libs \
openssl \
pcre \
zlib

RUN apk --no-cache --update add -t .build-deps \
apache2-dev \
apr-dev \
apr-util-dev \
build-base \
curl \
icu-dev \
libjpeg-turbo-dev \
linux-headers \
gperf \
openssl-dev \
pcre-dev \
python \
git \
zlib-dev

WORKDIR /tmp


RUN git clone --recursive https://github.com/google/ngx_brotli.git && \
wget https://github.com/apache/incubator-pagespeed-ngx/archive/v${PAGESPEED_VERSION}.zip && \
unzip v${PAGESPEED_VERSION}.zip && \
nps_dir=$(find . -name "*pagespeed-ngx-${PAGESPEED_VERSION}" -type d) && \
cd "$nps_dir" && \
NPS_RELEASE_NUMBER=${PAGESPEED_VERSION/stable/} && \
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_RELEASE_NUMBER}.tar.gz && \
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL) && \
wget ${psol_url} && \
tar -xzvf $(basename ${psol_url}) # extracts to psol/ && \
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
tar -xvzf nginx-${NGINX_VERSION}.tar.gz && \
cd nginx-${NGINX_VERSION}/ && \
./configure --add-module=$HOME/$nps_dir --add-module=$HOME/ngx_brotli ${PS_NGX_EXTRA_FLAGS} && \
make && \
make install

FROM alpine:3.8

COPY --from=buider /tmp/nginx-${NGINX_VERSION}/ /tmp/nginx

WORKDIR /tmp/nginx

RUN apk add --update --no-cache ca-certificates \
libuuid \
apr \
apr-util \
libjpeg-turbo \
icu \
icu-libs \
openssl \
pcre \
zlib \
make && \
make install && \
rm -rf /tmp/* && \
apk del make && \
# forward request and error logs to docker log collector
mkdir -p /var/log/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log && \
# Make PageSpeed cache writable:
mkdir -p /var/cache/ngx_pagespeed && \
chmod -R o+wr /var/cache/ngx_pagespeed
mv nginx-${NGINX_VERSION}/ nginx && \
cd nginx && \
./configure --with-compat --add-dynamic-module=/tmp/ngx_brotli && \
make modules

EXPOSE 80 443
FROM pagespeed/nginx-pagespeed

CMD ["nginx", "-g", "daemon off;"]
COPY --from=buider /tmp/nginx/objs/ngx_http_brotli_static_module.so /etc/nginx/modules
COPY --from=buider /tmp/nginx/objs/ngx_http_brotli_filter_module.so /etc/nginx/modules

0 comments on commit 8d5c24b

Please sign in to comment.