forked from devgeniem/ubuntu-docker-openresty-pagespeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
134 lines (120 loc) · 4.8 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
132
133
134
ARG SOURCEIMAGE="vsalomaki/docker-base:22.04.04"
# Carries pagespeed only in the name for now..
FROM $SOURCEIMAGE as nginxbuilder
LABEL maintainer="[email protected]"
#Forked from files by Ville Pietarinen / Geniem Oy
# Build Arguments for openresty/nginx
ARG NGX_PURGE_VERSION="2.3"
ARG NGX_PURGE_VERSION_SHA256="279e0d8a46d3b1521fd43b3f78bc1c08b263899142a7cc5058c1c0361a92c89c"
ARG RESTY_OPENSSL_VERSION="1.1.1q"
ARG RESTY_OPENSSL_VERSION_SHA256="d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca"
ARG RESTY_VERSION="1.21.4.1"
ARG RESTY_VERSION_SHA256="0c5093b64f7821e85065c99e5d4e6cc31820cfd7f37b9a0dec84209d87a2af99"
# Fix apt-get and show colors
ARG DEBIAN_FRONTEND=noninteractive
ARG TERM=xterm-color
ARG RESTY_CONFIG_OPTIONS="\
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-http_geoip_module=dynamic \
--with-file-aio \
--with-ipv6 \
--with-pcre-jit \
--with-stream \
--with-stream_ssl_module \
--with-threads \
#--without-debug \
--without-http_autoindex_module \
--without-http_browser_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_referer_module \
#--without-http_redis_module \
--user=nginx \
--group=nginx \
--sbin-path=/usr/sbin \
--modules-path=/usr/lib/nginx \
--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 \
--lock-path=/var/run/nginx/nginx.lock \
--http-fastcgi-temp-path=/tmp/nginx/fastcgi \
--http-proxy-temp-path=/tmp/nginx/proxy \
--http-client-body-temp-path=/tmp/nginx/client_body \
--add-module=/tmp/ngx_cache_purge-${NGX_PURGE_VERSION} \
--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} \
"
# These are only needed during the installation
ARG BUILD_DEPS='build-essential curl libreadline-dev libncurses5-dev libpcre3 libpcre3-dev libgeoip-dev \
zlib1g-dev ca-certificates perl make libssl-dev unzip uuid-dev'
RUN \
apt update && \
apt upgrade -y && \
apt install -y $BUILD_DEPS --no-install-recommends
WORKDIR /tmp
RUN \
### Download nginx cache purge module ###
echo "Downloading Nginx cache purge module..." && \
curl -o download.tar.gz http://labs.frickle.com/files/ngx_cache_purge-${NGX_PURGE_VERSION}.tar.gz && \
echo "${NGX_PURGE_VERSION_SHA256} download.tar.gz" | sha256sum -c && \
tar zxf download.tar.gz
RUN \
# Download OpenSSL
echo "Downloading OpenSSL..." && \
curl -o download.tar.gz https://www.openssl.org/source/openssl-${RESTY_OPENSSL_VERSION}.tar.gz && \
echo "${RESTY_OPENSSL_VERSION_SHA256} download.tar.gz" | sha256sum -c && \
tar zxf download.tar.gz
RUN \
# Download Openresty bundle
echo "Downloading openresty..." && \
curl -o download.tar.gz https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz && \
echo "${RESTY_VERSION_SHA256} download.tar.gz" | sha256sum -c && \
tar zxf download.tar.gz
RUN \
# Use all cores available in the builds with -j${NPROC} flag
readonly NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
echo "using up to $NPROC threads" && \
### Configure Nginx ###
cd openresty-${RESTY_VERSION} && \
./configure -j${NPROC} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} && \
# Build Nginx
make -j${NPROC} && \
make -j${NPROC} install && \
## Cleanup
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* /var/log/apt/*
FROM $SOURCEIMAGE
COPY --from=nginxbuilder /usr/sbin/nginx /usr/sbin/nginx
COPY --from=nginxbuilder /usr/lib/nginx /usr/lib/nginx
COPY --from=nginxbuilder /etc/nginx /etc/nginx
RUN \
# Temp directory
mkdir /tmp/nginx/ \
&& mkdir -p /var/lib/nginx /var/log/nginx \
# Symlink modules path to config path for easier usage
&& ln -sf /usr/lib/nginx /etc/nginx/modules \
# Create nginx group
&& groupadd -g 8888 nginx \
&& useradd -u 8888 -g nginx nginx \
# Symlink nginx logs to system output
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log