|
| 1 | +FROM alpine:3.8 |
| 2 | + |
| 3 | +LABEL maintainer= "NGINX Docker Maintainers <[email protected]>" |
| 4 | + |
| 5 | +ENV NGINX_VERSION 1.14.2 |
| 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-threads \ |
| 41 | + --with-stream \ |
| 42 | + --with-stream_ssl_module \ |
| 43 | + --with-stream_ssl_preread_module \ |
| 44 | + --with-stream_realip_module \ |
| 45 | + --with-stream_geoip_module=dynamic \ |
| 46 | + --with-http_slice_module \ |
| 47 | + --with-mail \ |
| 48 | + --with-mail_ssl_module \ |
| 49 | + --with-compat \ |
| 50 | + --with-file-aio \ |
| 51 | + --with-http_v2_module \ |
| 52 | + " \ |
| 53 | + && addgroup -S nginx \ |
| 54 | + && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \ |
| 55 | + && apk add --no-cache --virtual .build-deps \ |
| 56 | + gcc \ |
| 57 | + libc-dev \ |
| 58 | + make \ |
| 59 | + openssl-dev \ |
| 60 | + pcre-dev \ |
| 61 | + zlib-dev \ |
| 62 | + linux-headers \ |
| 63 | + curl \ |
| 64 | + gnupg1 \ |
| 65 | + libxslt-dev \ |
| 66 | + gd-dev \ |
| 67 | + geoip-dev \ |
| 68 | + && curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \ |
| 69 | + && curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \ |
| 70 | + && export GNUPGHOME="$(mktemp -d)" \ |
| 71 | + && found=''; \ |
| 72 | + for server in \ |
| 73 | + ha.pool.sks-keyservers.net \ |
| 74 | + hkp://keyserver.ubuntu.com:80 \ |
| 75 | + hkp://p80.pool.sks-keyservers.net:80 \ |
| 76 | + pgp.mit.edu \ |
| 77 | + ; do \ |
| 78 | + echo "Fetching GPG key $GPG_KEYS from $server"; \ |
| 79 | + gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ |
| 80 | + done; \ |
| 81 | + test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ |
| 82 | + gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \ |
| 83 | + && rm -rf "$GNUPGHOME" nginx.tar.gz.asc \ |
| 84 | + && mkdir -p /usr/src \ |
| 85 | + && tar -zxC /usr/src -f nginx.tar.gz \ |
| 86 | + && rm nginx.tar.gz \ |
| 87 | + && cd /usr/src/nginx-$NGINX_VERSION \ |
| 88 | + && ./configure $CONFIG --with-debug \ |
| 89 | + && make -j$(getconf _NPROCESSORS_ONLN) \ |
| 90 | + && mv objs/nginx objs/nginx-debug \ |
| 91 | + && mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \ |
| 92 | + && mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \ |
| 93 | + && mv objs/ngx_http_geoip_module.so objs/ngx_http_geoip_module-debug.so \ |
| 94 | + && mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \ |
| 95 | + && ./configure $CONFIG \ |
| 96 | + && make -j$(getconf _NPROCESSORS_ONLN) \ |
| 97 | + && make install \ |
| 98 | + && rm -rf /etc/nginx/html/ \ |
| 99 | + && mkdir /etc/nginx/conf.d/ \ |
| 100 | + && mkdir -p /usr/share/nginx/html/ \ |
| 101 | + && install -m644 html/index.html /usr/share/nginx/html/ \ |
| 102 | + && install -m644 html/50x.html /usr/share/nginx/html/ \ |
| 103 | + && install -m755 objs/nginx-debug /usr/sbin/nginx-debug \ |
| 104 | + && install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \ |
| 105 | + && install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \ |
| 106 | + && install -m755 objs/ngx_http_geoip_module-debug.so /usr/lib/nginx/modules/ngx_http_geoip_module-debug.so \ |
| 107 | + && install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \ |
| 108 | + && ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \ |
| 109 | + && strip /usr/sbin/nginx* \ |
| 110 | + && strip /usr/lib/nginx/modules/*.so \ |
| 111 | + && rm -rf /usr/src/nginx-$NGINX_VERSION \ |
| 112 | + \ |
| 113 | + # Bring in gettext so we can get `envsubst`, then throw |
| 114 | + # the rest away. To do this, we need to install `gettext` |
| 115 | + # then move `envsubst` out of the way so `gettext` can |
| 116 | + # be deleted completely, then move `envsubst` back. |
| 117 | + && apk add --no-cache --virtual .gettext gettext \ |
| 118 | + && mv /usr/bin/envsubst /tmp/ \ |
| 119 | + \ |
| 120 | + && runDeps="$( \ |
| 121 | + scanelf --needed --nobanner --format '%n#p' /usr/sbin/nginx /usr/lib/nginx/modules/*.so /tmp/envsubst \ |
| 122 | + | tr ',' '\n' \ |
| 123 | + | sort -u \ |
| 124 | + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ |
| 125 | + )" \ |
| 126 | + && apk add --no-cache --virtual .nginx-rundeps $runDeps \ |
| 127 | + && apk del .build-deps \ |
| 128 | + && apk del .gettext \ |
| 129 | + && mv /tmp/envsubst /usr/local/bin/ \ |
| 130 | + \ |
| 131 | + # Bring in tzdata so users could set the timezones through the environment |
| 132 | + # variables |
| 133 | + && apk add --no-cache tzdata \ |
| 134 | + \ |
| 135 | + ### Amplify specific section starts here |
| 136 | + # make sure log files are agent-readable |
| 137 | + && touch /var/log/nginx/access.log \ |
| 138 | + && touch /var/log/nginx/error.log \ |
| 139 | + \ |
| 140 | + # Install packages required by agent |
| 141 | + && apk add --no-cache python \ |
| 142 | + procps \ |
| 143 | + util-linux \ |
| 144 | + py-pip \ |
| 145 | + \ |
| 146 | + # install packages required for agent build |
| 147 | + && apk add --no-cache --virtual .amplify\ |
| 148 | + python-dev \ |
| 149 | + build-base \ |
| 150 | + git \ |
| 151 | + linux-headers \ |
| 152 | + && cd / \ |
| 153 | + \ |
| 154 | + # clone latest agent from repository and build it |
| 155 | + && git clone https://github.com/nginxinc/nginx-amplify-agent \ |
| 156 | + && cd nginx-amplify-agent/ \ |
| 157 | + && pip install --no-cache-dir -r packages/nginx-amplify-agent/requirements.txt \ |
| 158 | + && python setup.py install \ |
| 159 | + \ |
| 160 | + # make sure agent log exists |
| 161 | + && mkdir -p /var/log/amplify-agent \ |
| 162 | + && touch /var/log/amplify-agent/agent.log \ |
| 163 | + \ |
| 164 | + # create agent config file |
| 165 | + && cp /etc/amplify-agent/agent.conf.default /etc/amplify-agent/agent.conf \ |
| 166 | + \ |
| 167 | + # Cleanup |
| 168 | + && cd .. \ |
| 169 | + && rm -Rf nginx-amplify-agent/ \ |
| 170 | + && find /usr/lib/python2.7 -name \*\.pyo -exec rm {} \; \ |
| 171 | + && find /usr/lib/python2.7 -name \*\.pyc -exec rm {} \; \ |
| 172 | + && apk del .amplify |
| 173 | + |
| 174 | +COPY ./entrypoint.sh /entrypoint.sh |
| 175 | +COPY conf/nginx.conf /etc/nginx/nginx.conf |
| 176 | +COPY conf/nginx.vh.default.conf /etc/nginx/conf.d/default.conf |
| 177 | +COPY conf/stub_status.conf /etc/nginx/conf.d/stub_status.conf |
| 178 | + |
| 179 | +EXPOSE 80 |
| 180 | + |
| 181 | +STOPSIGNAL SIGTERM |
| 182 | + |
| 183 | +ENTRYPOINT ["/entrypoint.sh"] |
0 commit comments