@@ -11,20 +11,107 @@ FROM jlesage/baseimage:alpine-3.9-v2.4.3
11
11
ARG DOCKER_IMAGE_VERSION=unknown
12
12
13
13
# Define software versions.
14
- ARG NGINX_PROXY_MANAGER_VERSION=2.2.4
14
+ ARG OPENRESTY_VERSION=1.17.8.1
15
+ ARG NGINX_PROXY_MANAGER_VERSION=2.3.1
15
16
16
17
# Define software download URLs.
18
+ ARG OPENRESTY_URL=https://openresty.org/download/openresty-${OPENRESTY_VERSION}.tar.gz
17
19
ARG NGINX_PROXY_MANAGER_URL=https://github.com/jc21/nginx-proxy-manager/archive/v${NGINX_PROXY_MANAGER_VERSION}.tar.gz
18
20
19
21
# Define working directory.
20
22
WORKDIR /tmp
21
23
24
+ # Build and install OpenResty (nginx).
25
+ RUN \
26
+ add-pkg --virtual build-dependencies \
27
+ build-base \
28
+ curl \
29
+ linux-headers \
30
+ perl \
31
+ pcre-dev \
32
+ openssl-dev \
33
+ zlib-dev \
34
+ && \
35
+ # Download.
36
+ echo "Downloading OpenResty..." && \
37
+ mkdir openresty && \
38
+ curl -# -L ${OPENRESTY_URL} | tar xz --strip 1 -C openresty && \
39
+ # Compile.
40
+ echo "Compiling OpenResty..." && \
41
+ cd openresty && \
42
+ ./configure -j$(nproc) \
43
+ --prefix=/var/lib/nginx \
44
+ --sbin-path=/usr/sbin/nginx \
45
+ --modules-path=/usr/lib/nginx/modules \
46
+ --conf-path=/etc/nginx/nginx.conf \
47
+ --pid-path=/var/run/nginx/nginx.pid \
48
+ --lock-path=/var/run/nginx/nginx.lock \
49
+ --error-log-path=/config/log/nginx/error.log \
50
+ --http-log-path=/config/log/nginx/access.log \
51
+ \
52
+ --http-client-body-temp-path=/var/tmp/nginx/client_body \
53
+ --http-proxy-temp-path=/var/tmp/nginx/proxy \
54
+ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
55
+ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
56
+ --http-scgi-temp-path=/var/tmp/nginx/scgi \
57
+ --with-perl_modules_path=/usr/lib/perl5/vendor_perl \
58
+ \
59
+ --user=nginx \
60
+ --group=nginx \
61
+ --with-threads \
62
+ --with-file-aio \
63
+ \
64
+ --with-http_ssl_module \
65
+ --with-http_v2_module \
66
+ --with-http_realip_module \
67
+ --with-http_addition_module \
68
+ --with-http_sub_module \
69
+ --with-http_dav_module \
70
+ --with-http_flv_module \
71
+ --with-http_mp4_module \
72
+ --with-http_gunzip_module \
73
+ --with-http_gzip_static_module \
74
+ --with-http_auth_request_module \
75
+ --with-http_random_index_module \
76
+ --with-http_secure_link_module \
77
+ --with-http_degradation_module \
78
+ --with-http_slice_module \
79
+ --with-http_stub_status_module \
80
+ --with-stream \
81
+ --with-stream_ssl_module \
82
+ --with-stream_realip_module \
83
+ --with-stream_ssl_preread_module \
84
+ --with-pcre-jit \
85
+ && \
86
+ make -j$(nproc) && \
87
+ # Install.
88
+ echo "Installing OpenResty..." && \
89
+ make install && \
90
+ find /var/lib/nginx/ -type f -name '*.so*' -exec strip {} ';' && \
91
+ strip /usr/sbin/nginx && \
92
+ cd .. && \
93
+ # Cleanup.
94
+ del-pkg build-dependencies && \
95
+ rm -r \
96
+ /var/lib/nginx/bin/opm \
97
+ /var/lib/nginx/bin/nginx-xml2pod \
98
+ /var/lib/nginx/bin/restydoc-index \
99
+ /var/lib/nginx/bin/restydoc \
100
+ /var/lib/nginx/bin/md2pod.pl \
101
+ /var/lib/nginx/luajit/include \
102
+ /var/lib/nginx/luajit/lib/libluajit-5.1.a \
103
+ /var/lib/nginx/luajit/lib/pkgconfig \
104
+ /var/lib/nginx/luajit/share/man \
105
+ /var/lib/nginx/pod \
106
+ /var/lib/nginx/resty.index \
107
+ /var/lib/nginx/site \
108
+ && \
109
+ rm -rf /tmp/* /tmp/.[!.]*
110
+
22
111
# Install dependencies.
23
112
RUN \
24
113
add-pkg \
25
114
nodejs \
26
- nginx \
27
- nginx-mod-stream \
28
115
mariadb \
29
116
mariadb-client \
30
117
mariadb-server-utils \
@@ -39,25 +126,6 @@ RUN \
39
126
rm -r \
40
127
/var/lib/mysql \
41
128
&& \
42
- # Clean some uneeded stuff from nginx.
43
- mv /etc/nginx/fastcgi.conf /tmp/ && \
44
- mv /etc/nginx/fastcgi_params /tmp/ && \
45
- rm -r \
46
- /var/log/nginx \
47
- /var/lib/nginx \
48
- /var/tmp/nginx \
49
- /etc/nginx \
50
- /etc/init.d/nginx \
51
- /etc/logrotate.d/nginx \
52
- /var/www && \
53
- mkdir /etc/nginx && \
54
- mv /tmp/fastcgi.conf /etc/nginx/ && \
55
- mv /tmp/fastcgi_params /etc/nginx/ && \
56
- ln -s /tmp/nginx /var/tmp/nginx && \
57
- # nginx always tries to open /var/lib/nginx/logs/error.log before reading
58
- # its configuration. Make sure it exists.
59
- mkdir -p /var/lib/nginx/logs && \
60
- ln -sf /config/log/nginx/error.log /var/lib/nginx/logs/error.log && \
61
129
# Make sure mariadb listen on port 3306
62
130
sed-patch 's/^skip-networking/#skip-networking/' /etc/my.cnf.d/mariadb-server.cnf
63
131
@@ -143,8 +211,17 @@ RUN \
143
211
# Remove the `user` directive, since we want nginx to run as non-root.
144
212
sed-patch 's|user root;|#user root;|' /etc/nginx/nginx.conf && \
145
213
146
- # Make sure nginx loads the stream module.
147
- sed-patch '/daemon off;/a load_module /usr/lib/nginx/modules/ngx_stream_module.so;' /etc/nginx/nginx.conf && \
214
+ # Change log paths.
215
+ sed-patch 's|/data/logs/|/config/log/|' /etc/nginx/nginx.conf && \
216
+ sed-patch 's|/data/logs/|/config/log/|' /etc/nginx/conf.d/default.conf && \
217
+ sed-patch 's|/data/logs/|/config/log/|' /opt/nginx-proxy-manager/templates/dead_host.conf && \
218
+ sed-patch 's|/data/logs/|/config/log/|' /opt/nginx-proxy-manager/templates/default.conf && \
219
+ sed-patch 's|/data/logs/|/config/log/|' /opt/nginx-proxy-manager/templates/letsencrypt-request.conf && \
220
+ sed-patch 's|/data/logs/|/config/log/|' /opt/nginx-proxy-manager/templates/proxy_host.conf && \
221
+ sed-patch 's|/data/logs/|/config/log/|' /opt/nginx-proxy-manager/templates/redirection_host.conf && \
222
+
223
+ # Change client_body_temp_path.
224
+ sed-patch 's|/tmp/nginx/body|/var/tmp/nginx/body|' /etc/nginx/nginx.conf && \
148
225
149
226
# Redirect `/data' to '/config'.
150
227
ln -s /config /data && \
@@ -153,7 +230,7 @@ RUN \
153
230
mv /etc/nginx/conf.d/include/ip_ranges.conf /defaults/ && \
154
231
ln -sf /config/nginx/ip_ranges.conf /etc/nginx/conf.d/include/ip_ranges.conf && \
155
232
156
- # Make sure the config file for resovers is stored in persistent volume.
233
+ # Make sure the config file for resolvers is stored in persistent volume.
157
234
ln -sf /config/nginx/resolvers.conf /etc/nginx/conf.d/include/resolvers.conf && \
158
235
159
236
# Make sure nginx cache is stored on the persistent volume.
0 commit comments