-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
61 lines (53 loc) · 2.05 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
ARG BASE_IMAGE=registry.gitlab.com/thelabnyc/python:py313
FROM ${BASE_IMAGE}
# Environment Settings
ENV GEOIP_PATH "/data/geo"
ENV GEOIP_COUNTRY "GeoLite2-Country.mmdb"
ENV GEOIP_CITY "GeoLite2-City.mmdb"
ENV LIBMAXMINDDB_VERSION "1.6.0"
# Create directories
RUN mkdir -p "$GEOIP_PATH"
# Install GeoIP2 C library
# See https://docs.djangoproject.com/en/dev/ref/contrib/gis/geoip2/
RUN cd "/tmp/" && \
wget --quiet "https://github.com/maxmind/libmaxminddb/releases/download/$LIBMAXMINDDB_VERSION/libmaxminddb-$LIBMAXMINDDB_VERSION.tar.gz" && \
tar -zxf "libmaxminddb-$LIBMAXMINDDB_VERSION.tar.gz" && \
rm "libmaxminddb-$LIBMAXMINDDB_VERSION.tar.gz" && \
cd "/tmp/libmaxminddb-$LIBMAXMINDDB_VERSION/" && \
./configure && \
make && \
make check && \
make install && \
ldconfig && \
rm -r "/tmp/libmaxminddb-$LIBMAXMINDDB_VERSION"
# Accept Maxmind License Key as a build arg
# See https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/
ARG MAXMIND_LICENSE_KEY
# Add and unzip the GeoIP2 databases
COPY data/* "$GEOIP_PATH/"
RUN cd "$GEOIP_PATH" && \
tar xvzf "$GEOIP_PATH/$GEOIP_COUNTRY.tar.gz" && \
mv $GEOIP_PATH/GeoLite2-Country_*/* "$GEOIP_PATH/" && \
rmdir $GEOIP_PATH/GeoLite2-Country_* && \
rm "$GEOIP_PATH/$GEOIP_COUNTRY.tar.gz"
RUN cd "$GEOIP_PATH" && \
tar xvzf "$GEOIP_PATH/$GEOIP_CITY.tar.gz" && \
mv $GEOIP_PATH/GeoLite2-City_*/* "$GEOIP_PATH/" && \
rmdir $GEOIP_PATH/GeoLite2-City_* && \
rm "$GEOIP_PATH/$GEOIP_CITY.tar.gz"
# Install the GeoIP Python library
RUN pip install --no-cache-dir --upgrade "geoip2"
# Install IPython, because it's nice to have
RUN pip install --no-cache-dir --upgrade "ipython"
# Optionally install Geospatial libraries
ARG GEOSPATIAL
RUN if [ "$GEOSPATIAL" = "true" ]; then \
export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install -yq \
binutils \
libproj-dev \
gdal-bin; \
rm -rf /var/lib/apt/lists/*; \
unset DEBIAN_FRONTEND; \
fi