forked from lagunovsky/docker-nginx-pagespeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
131 lines (123 loc) · 6.33 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
FROM alpine:3.4
MAINTAINER [email protected]
ENV NGINX_VERSION=1.13.4 \
PAGESPEED_VERSION=1.11.33.4 \
LIBPNG_VERSION=1.2.56 \
MAKE_J=4 \
PAGESPEED_ENABLE=on
RUN apk upgrade --no-cache --update && \
apk add --no-cache --update \
bash \
ca-certificates \
libuuid \
apr \
apr-util \
libjpeg-turbo \
icu \
icu-libs \
openssl \
pcre \
zlib
RUN set -x && \
apk --no-cache 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 \
zlib-dev && \
addgroup -g 1000 -S nginx && \
adduser -u 1000 -D -S -h /var/cache/ngx_pagespeed -s /sbin/nologin -G nginx nginx && \
# Build libpng
cd /tmp && \
curl -L http://prdownloads.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz | tar -zx && \
cd /tmp/libpng-${LIBPNG_VERSION} && \
./configure --build=$CBUILD --host=$CHOST --prefix=/usr --enable-shared --with-libpng-compat && \
make -j${MAKE_J} install V=0 && \
# Build PageSpeed
cd /tmp && \
curl -L https://dl.google.com/dl/linux/mod-pagespeed/tar/beta/mod-pagespeed-beta-${PAGESPEED_VERSION}-r0.tar.bz2 | tar -jx && \
curl -L https://github.com/pagespeed/ngx_pagespeed/archive/v${PAGESPEED_VERSION}-beta.tar.gz | tar -zx && \
cd /tmp/modpagespeed-${PAGESPEED_VERSION} && \
curl -L https://raw.githubusercontent.com/lagun4ik/docker-nginx-pagespeed/master/patches/automatic_makefile.patch | patch -p1 && \
curl -L https://raw.githubusercontent.com/lagun4ik/docker-nginx-pagespeed/master/patches/libpng_cflags.patch | patch -p1 && \
curl -L https://raw.githubusercontent.com/lagun4ik/docker-nginx-pagespeed/master/patches/pthread_nonrecursive_np.patch | patch -p1 && \
curl -L https://raw.githubusercontent.com/lagun4ik/docker-nginx-pagespeed/master/patches/rename_c_symbols.patch | patch -p1 && \
curl -L https://raw.githubusercontent.com/lagun4ik/docker-nginx-pagespeed/master/patches/stack_trace_posix.patch | patch -p1 && \
./generate.sh -D use_system_libs=1 -D _GLIBCXX_USE_CXX11_ABI=0 -D use_system_icu=1 && \
cd /tmp/modpagespeed-${PAGESPEED_VERSION}/src && \
make -j${MAKE_J} BUILDTYPE=Release CXXFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" CFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" && \
cd /tmp/modpagespeed-${PAGESPEED_VERSION}/src/pagespeed/automatic/ && \
make -j${MAKE_J} psol BUILDTYPE=Release CXXFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" CFLAGS=" -I/usr/include/apr-1 -I/tmp/libpng-${LIBPNG_VERSION} -fPIC -D_GLIBCXX_USE_CXX11_ABI=0" && \
mkdir -p /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol && \
mkdir -p /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/lib/Release/linux/x64 && \
mkdir -p /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/out/Release && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/out/Release/obj /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/out/Release/ && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/net /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/testing /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/pagespeed /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/third_party /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/tools /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/url /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/include/ && \
cp -r /tmp/modpagespeed-${PAGESPEED_VERSION}/src/pagespeed/automatic/pagespeed_automatic.a /tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta/psol/lib/Release/linux/x64 && \
# Build Nginx with support for PageSpeed
cd /tmp && \
curl -L http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -zx && \
cd /tmp/nginx-${NGINX_VERSION} && \
LD_LIBRARY_PATH=/tmp/modpagespeed-${PAGESPEED_VERSION}/usr/lib ./configure \
--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 \
--with-http_realip_module \
--without-http_autoindex_module \
--without-http_browser_module \
--without-http_geo_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_uwsgi_module \
--without-http_scgi_module \
--without-http_upstream_ip_hash_module \
--with-http_sub_module \
--with-http_gunzip_module \
--with-http_secure_link_module \
--with-threads \
--with-stream \
--with-stream_ssl_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 \
--add-module=/tmp/ngx_pagespeed-${PAGESPEED_VERSION}-beta \
--with-cc-opt="-fPIC -I /usr/include/apr-1" \
--with-ld-opt="-luuid -lapr-1 -laprutil-1 -licudata -licuuc -L/tmp/modpagespeed-${PAGESPEED_VERSION}/usr/lib -lpng12 -lturbojpeg -ljpeg" && \
make -j${MAKE_J} install --silent && \
# Clean-up
cd && \
apk del .build-deps && \
rm -rf /tmp/* && \
# Forward request and error logs to docker log collector
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
COPY config/conf.d /etc/nginx/conf.d
COPY config/nginx.conf /etc/nginx/nginx.conf
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
VOLUME ["/var/cache/ngx_pagespeed"]
EXPOSE 80 443
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]