@@ -13,11 +13,15 @@ ARG DOCKER_IMAGE_VERSION=unknown
1313# Define software versions.
1414ARG OPENRESTY_VERSION=1.19.3.1
1515ARG NGINX_PROXY_MANAGER_VERSION=2.7.3
16+ ARG NGINX_HTTP_GEOIP2_MODULE_VERSION=3.3
17+ ARG LIBMAXMINDDB_VERSION=1.5.0
1618ARG WATCH_VERSION=0.3.1
1719
1820# Define software download URLs.
1921ARG OPENRESTY_URL=https://openresty.org/download/openresty-${OPENRESTY_VERSION}.tar.gz
2022ARG NGINX_PROXY_MANAGER_URL=https://github.com/jc21/nginx-proxy-manager/archive/v${NGINX_PROXY_MANAGER_VERSION}.tar.gz
23+ ARG NGINX_HTTP_GEOIP2_MODULE_URL=https://github.com/leev/ngx_http_geoip2_module/archive/${NGINX_HTTP_GEOIP2_MODULE_VERSION}.tar.gz
24+ ARG LIBMAXMINDDB_URL=https://github.com/maxmind/libmaxminddb/releases/download/${LIBMAXMINDDB_VERSION}/libmaxminddb-${LIBMAXMINDDB_VERSION}.tar.gz
2125ARG WATCH_URL=https://github.com/tj/watch/archive/${WATCH_VERSION}.tar.gz
2226
2327# Define working directory.
6064 pcre-dev \
6165 openssl-dev \
6266 zlib-dev \
63- geoip-dev \
6467 && \
6568 # Set same default compilation flags as abuild.
6669 export CFLAGS="-Os -fomit-frame-pointer" && \
7174 echo "Downloading OpenResty..." && \
7275 mkdir openresty && \
7376 curl -# -L ${OPENRESTY_URL} | tar xz --strip 1 -C openresty && \
77+ echo "Downloading GeoIP2 module..." && \
78+ mkdir ngx_http_geoip2_module && \
79+ curl -# -L ${NGINX_HTTP_GEOIP2_MODULE_URL} | tar xz --strip 1 -C ngx_http_geoip2_module && \
80+ echo "Downloading libmaxminddb..." && \
81+ mkdir libmaxminddb && \
82+ curl -# -L ${LIBMAXMINDDB_URL} | tar xz --strip 1 -C libmaxminddb && \
7483 # Compile.
84+ echo "Compiling libmaxminddb..." && \
85+ cd libmaxminddb && \
86+ ./configure \
87+ --prefix=/usr \
88+ --mandir=/tmp/libmaxminddb-man \
89+ --with-pic \
90+ --enable-shared=no \
91+ --enable-static=yes \
92+ && \
93+ make -j$(nproc) install && \
94+ cd .. && \
7595 echo "Compiling OpenResty..." && \
7696 cd openresty && \
7797 ./configure -j$(nproc) \
@@ -112,13 +132,13 @@ RUN \
112132 --with-http_degradation_module \
113133 --with-http_slice_module \
114134 --with-http_stub_status_module \
115- --with-http_geoip_module \
116135 --with-stream \
117136 --with-stream_ssl_module \
118137 --with-stream_realip_module \
119138 --with-stream_ssl_preread_module \
120- --with-stream_geoip_module \
121139 --with-pcre-jit \
140+ \
141+ --add-module=/tmp/ngx_http_geoip2_module \
122142 && \
123143 make -j$(nproc) && \
124144 # Install.
@@ -144,6 +164,13 @@ RUN \
144164 /var/lib/nginx/resty.index \
145165 /var/lib/nginx/site \
146166 && \
167+ rm \
168+ /usr/include/maxminddb*.h \
169+ /usr/lib/libmaxminddb* \
170+ /usr/lib/pkgconfig/libmaxminddb.pc \
171+ && \
172+ [ -n "$(ls /usr/include)" ] || rm -r /usr/include && \
173+ [ -n "$(ls /usr/lib/pkgconfig)" ] || rm -r /usr/lib/pkgconfig && \
147174 rm -rf /tmp/* /tmp/.[!.]*
148175
149176# Install dependencies.
@@ -160,7 +187,6 @@ RUN \
160187 bash \
161188 # For openresty
162189 pcre \
163- geoip \
164190 && \
165191 # Adjust the logrotate config file.
166192 sed-patch 's|^/var/log/messages|#/var/log/messages|' /etc/logrotate.conf
0 commit comments