Skip to content

Commit ec7ff8c

Browse files
committed
Ported changes from stable to mainline.
There are breaking changes! - Alpine images now use 3.5 as a base. (refs: nginx#136) - Debian images now use Debian 9 "Stretch" as a base, stretch-slim variant. (refs: nginx#76) - Removed nginx perl module from default images and moved it to a separate -perl tag. (refs: nginx#154) - Removed ca-certificates from Debian-based images as it greatly affects image size on stretch. (refs: nginx#12) - Port 443 is no longer exposed by default since nginx does not listen on it. (refs: nginx#130) - Explicitely set nginx and modules versions. (refs: nginx#141) - Defined default stop signal as QUIT to allow graceful shutdown. (refs: nginx#46)
1 parent 4d1f7f8 commit ec7ff8c

File tree

6 files changed

+287
-19
lines changed

6 files changed

+287
-19
lines changed

mainline/alpine-perl/Dockerfile

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
FROM alpine:3.5
2+
3+
MAINTAINER NGINX Docker Maintainers "[email protected]"
4+
5+
ENV NGINX_VERSION 1.11.13
6+
7+
RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
8+
&& CONFIG="\
9+
--prefix=/etc/nginx \
10+
--sbin-path=/usr/sbin/nginx \
11+
--modules-path=/usr/lib/nginx/modules \
12+
--conf-path=/etc/nginx/nginx.conf \
13+
--error-log-path=/var/log/nginx/error.log \
14+
--http-log-path=/var/log/nginx/access.log \
15+
--pid-path=/var/run/nginx.pid \
16+
--lock-path=/var/run/nginx.lock \
17+
--http-client-body-temp-path=/var/cache/nginx/client_temp \
18+
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
19+
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
20+
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
21+
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
22+
--user=nginx \
23+
--group=nginx \
24+
--with-http_ssl_module \
25+
--with-http_realip_module \
26+
--with-http_addition_module \
27+
--with-http_sub_module \
28+
--with-http_dav_module \
29+
--with-http_flv_module \
30+
--with-http_mp4_module \
31+
--with-http_gunzip_module \
32+
--with-http_gzip_static_module \
33+
--with-http_random_index_module \
34+
--with-http_secure_link_module \
35+
--with-http_stub_status_module \
36+
--with-http_auth_request_module \
37+
--with-http_xslt_module=dynamic \
38+
--with-http_image_filter_module=dynamic \
39+
--with-http_geoip_module=dynamic \
40+
--with-http_perl_module=dynamic \
41+
--with-threads \
42+
--with-stream \
43+
--with-stream_ssl_module \
44+
--with-stream_ssl_preread_module \
45+
--with-stream_realip_module \
46+
--with-stream_geoip_module=dynamic \
47+
--with-http_slice_module \
48+
--with-mail \
49+
--with-mail_ssl_module \
50+
--with-compat \
51+
--with-file-aio \
52+
--with-http_v2_module \
53+
" \
54+
&& addgroup -S nginx \
55+
&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
56+
&& apk add --no-cache --virtual .build-deps \
57+
gcc \
58+
libc-dev \
59+
make \
60+
openssl-dev \
61+
pcre-dev \
62+
zlib-dev \
63+
linux-headers \
64+
curl \
65+
gnupg \
66+
libxslt-dev \
67+
gd-dev \
68+
geoip-dev \
69+
perl-dev \
70+
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \
71+
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \
72+
&& export GNUPGHOME="$(mktemp -d)" \
73+
&& found=''; \
74+
for server in \
75+
ha.pool.sks-keyservers.net \
76+
hkp://keyserver.ubuntu.com:80 \
77+
hkp://p80.pool.sks-keyservers.net:80 \
78+
pgp.mit.edu \
79+
; do \
80+
echo "Fetching GPG key $GPG_KEYS from $server"; \
81+
gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \
82+
done; \
83+
test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \
84+
gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \
85+
&& rm -r "$GNUPGHOME" nginx.tar.gz.asc \
86+
&& mkdir -p /usr/src \
87+
&& tar -zxC /usr/src -f nginx.tar.gz \
88+
&& rm nginx.tar.gz \
89+
&& cd /usr/src/nginx-$NGINX_VERSION \
90+
&& ./configure $CONFIG --with-debug \
91+
&& make -j$(getconf _NPROCESSORS_ONLN) \
92+
&& mv objs/nginx objs/nginx-debug \
93+
&& mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \
94+
&& mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \
95+
&& mv objs/ngx_http_geoip_module.so objs/ngx_http_geoip_module-debug.so \
96+
&& mv objs/ngx_http_perl_module.so objs/ngx_http_perl_module-debug.so \
97+
&& mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \
98+
&& ./configure $CONFIG \
99+
&& make -j$(getconf _NPROCESSORS_ONLN) \
100+
&& make install \
101+
&& rm -rf /etc/nginx/html/ \
102+
&& mkdir /etc/nginx/conf.d/ \
103+
&& mkdir -p /usr/share/nginx/html/ \
104+
&& install -m644 html/index.html /usr/share/nginx/html/ \
105+
&& install -m644 html/50x.html /usr/share/nginx/html/ \
106+
&& install -m755 objs/nginx-debug /usr/sbin/nginx-debug \
107+
&& install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \
108+
&& install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \
109+
&& install -m755 objs/ngx_http_geoip_module-debug.so /usr/lib/nginx/modules/ngx_http_geoip_module-debug.so \
110+
&& install -m755 objs/ngx_http_perl_module-debug.so /usr/lib/nginx/modules/ngx_http_perl_module-debug.so \
111+
&& install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \
112+
&& ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \
113+
&& strip /usr/sbin/nginx* \
114+
&& strip /usr/lib/nginx/modules/*.so \
115+
&& rm -rf /usr/src/nginx-$NGINX_VERSION \
116+
\
117+
# Bring in gettext so we can get `envsubst`, then throw
118+
# the rest away. To do this, we need to install `gettext`
119+
# then move `envsubst` out of the way so `gettext` can
120+
# be deleted completely, then move `envsubst` back.
121+
&& apk add --no-cache --virtual .gettext gettext \
122+
&& mv /usr/bin/envsubst /tmp/ \
123+
\
124+
&& runDeps="$( \
125+
scanelf --needed --nobanner /usr/sbin/nginx /usr/lib/nginx/modules/*.so /tmp/envsubst \
126+
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
127+
| sort -u \
128+
| xargs -r apk info --installed \
129+
| sort -u \
130+
)" \
131+
&& apk add --no-cache --virtual .nginx-rundeps $runDeps \
132+
&& apk del .build-deps \
133+
&& apk del .gettext \
134+
&& mv /tmp/envsubst /usr/local/bin/ \
135+
\
136+
# forward request and error logs to docker log collector
137+
&& ln -sf /dev/stdout /var/log/nginx/access.log \
138+
&& ln -sf /dev/stderr /var/log/nginx/error.log
139+
140+
COPY nginx.conf /etc/nginx/nginx.conf
141+
COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf
142+
143+
EXPOSE 80
144+
145+
STOPSIGNAL SIGQUIT
146+
147+
CMD ["nginx", "-g", "daemon off;"]

mainline/alpine-perl/nginx.conf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
user nginx;
3+
worker_processes 1;
4+
5+
error_log /var/log/nginx/error.log warn;
6+
pid /var/run/nginx.pid;
7+
8+
9+
events {
10+
worker_connections 1024;
11+
}
12+
13+
14+
http {
15+
include /etc/nginx/mime.types;
16+
default_type application/octet-stream;
17+
18+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
19+
'$status $body_bytes_sent "$http_referer" '
20+
'"$http_user_agent" "$http_x_forwarded_for"';
21+
22+
access_log /var/log/nginx/access.log main;
23+
24+
sendfile on;
25+
#tcp_nopush on;
26+
27+
keepalive_timeout 65;
28+
29+
#gzip on;
30+
31+
include /etc/nginx/conf.d/*.conf;
32+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
#charset koi8-r;
6+
#access_log /var/log/nginx/log/host.access.log main;
7+
8+
location / {
9+
root /usr/share/nginx/html;
10+
index index.html index.htm;
11+
}
12+
13+
#error_page 404 /404.html;
14+
15+
# redirect server error pages to the static page /50x.html
16+
#
17+
error_page 500 502 503 504 /50x.html;
18+
location = /50x.html {
19+
root /usr/share/nginx/html;
20+
}
21+
22+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
23+
#
24+
#location ~ \.php$ {
25+
# proxy_pass http://127.0.0.1;
26+
#}
27+
28+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
29+
#
30+
#location ~ \.php$ {
31+
# root html;
32+
# fastcgi_pass 127.0.0.1:9000;
33+
# fastcgi_index index.php;
34+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
35+
# include fastcgi_params;
36+
#}
37+
38+
# deny access to .htaccess files, if Apache's document root
39+
# concurs with nginx's one
40+
#
41+
#location ~ /\.ht {
42+
# deny all;
43+
#}
44+
}
45+

mainline/alpine/Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.4
1+
FROM alpine:3.5
22

33
MAINTAINER NGINX Docker Maintainers "[email protected]"
44

@@ -37,7 +37,6 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
3737
--with-http_xslt_module=dynamic \
3838
--with-http_image_filter_module=dynamic \
3939
--with-http_geoip_module=dynamic \
40-
--with-http_perl_module=dynamic \
4140
--with-threads \
4241
--with-stream \
4342
--with-stream_ssl_module \
@@ -66,7 +65,6 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
6665
libxslt-dev \
6766
gd-dev \
6867
geoip-dev \
69-
perl-dev \
7068
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \
7169
&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \
7270
&& export GNUPGHOME="$(mktemp -d)" \
@@ -93,7 +91,6 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
9391
&& mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \
9492
&& mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \
9593
&& mv objs/ngx_http_geoip_module.so objs/ngx_http_geoip_module-debug.so \
96-
&& mv objs/ngx_http_perl_module.so objs/ngx_http_perl_module-debug.so \
9794
&& mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \
9895
&& ./configure $CONFIG \
9996
&& make -j$(getconf _NPROCESSORS_ONLN) \
@@ -107,7 +104,6 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
107104
&& install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \
108105
&& install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \
109106
&& install -m755 objs/ngx_http_geoip_module-debug.so /usr/lib/nginx/modules/ngx_http_geoip_module-debug.so \
110-
&& install -m755 objs/ngx_http_perl_module-debug.so /usr/lib/nginx/modules/ngx_http_perl_module-debug.so \
111107
&& install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \
112108
&& ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \
113109
&& strip /usr/sbin/nginx* \
@@ -140,6 +136,8 @@ RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \
140136
COPY nginx.conf /etc/nginx/nginx.conf
141137
COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf
142138

143-
EXPOSE 80 443
139+
EXPOSE 80
140+
141+
STOPSIGNAL SIGQUIT
144142

145143
CMD ["nginx", "-g", "daemon off;"]

mainline/stretch-perl/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM debian:stretch-slim
2+
3+
MAINTAINER NGINX Docker Maintainers "[email protected]"
4+
5+
ENV NGINX_VERSION 1.11.13-1~stretch
6+
ENV NJS_VERSION 1.11.13.0.1.10-1~stretch
7+
8+
RUN apt-get update \
9+
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 \
10+
&& \
11+
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
12+
found=''; \
13+
for server in \
14+
ha.pool.sks-keyservers.net \
15+
hkp://keyserver.ubuntu.com:80 \
16+
hkp://p80.pool.sks-keyservers.net:80 \
17+
pgp.mit.edu \
18+
; do \
19+
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
20+
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
21+
done; \
22+
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
23+
apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* \
24+
&& echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
25+
&& apt-get update \
26+
&& apt-get install --no-install-recommends --no-install-suggests -y \
27+
nginx=${NGINX_VERSION} \
28+
nginx-module-xslt=${NGINX_VERSION} \
29+
nginx-module-geoip=${NGINX_VERSION} \
30+
nginx-module-image-filter=${NGINX_VERSION} \
31+
nginx-module-perl=${NGINX_VERSION} \
32+
nginx-module-njs=${NJS_VERSION} \
33+
gettext-base \
34+
&& rm -rf /var/lib/apt/lists/*
35+
36+
# forward request and error logs to docker log collector
37+
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
38+
&& ln -sf /dev/stderr /var/log/nginx/error.log
39+
40+
EXPOSE 80
41+
42+
STOPSIGNAL SIGQUIT
43+
44+
CMD ["nginx", "-g", "daemon off;"]
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
FROM debian:jessie
1+
FROM debian:stretch-slim
22

33
MAINTAINER NGINX Docker Maintainers "[email protected]"
44

5-
ENV NGINX_VERSION 1.11.13-1~jessie
5+
ENV NGINX_VERSION 1.11.13-1~stretch
6+
ENV NJS_VERSION 1.11.13.0.1.10-1~stretch
67

7-
RUN set -e; \
8+
RUN apt-get update \
9+
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 \
10+
&& \
811
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
912
found=''; \
1013
for server in \
@@ -17,25 +20,24 @@ RUN set -e; \
1720
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
1821
done; \
1922
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
20-
exit 0
21-
22-
RUN echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
23+
apt-get remove --purge -y gnupg1 && apt-get -y --purge autoremove && rm -rf /var/lib/apt/lists/* \
24+
&& echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list \
2325
&& apt-get update \
2426
&& apt-get install --no-install-recommends --no-install-suggests -y \
25-
ca-certificates \
2627
nginx=${NGINX_VERSION} \
27-
nginx-module-xslt \
28-
nginx-module-geoip \
29-
nginx-module-image-filter \
30-
nginx-module-perl \
31-
nginx-module-njs \
28+
nginx-module-xslt=${NGINX_VERSION} \
29+
nginx-module-geoip=${NGINX_VERSION} \
30+
nginx-module-image-filter=${NGINX_VERSION} \
31+
nginx-module-njs=${NJS_VERSION} \
3232
gettext-base \
3333
&& rm -rf /var/lib/apt/lists/*
3434

3535
# forward request and error logs to docker log collector
3636
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
3737
&& ln -sf /dev/stderr /var/log/nginx/error.log
3838

39-
EXPOSE 80 443
39+
EXPOSE 80
40+
41+
STOPSIGNAL SIGQUIT
4042

4143
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)