-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
64 lines (48 loc) · 2.01 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
62
63
64
############################################################
# Dockerfile to create GeoLite2 Country and City databases
# with automatic weekly updates.
#
# Adapted from tkrs/maxmind-lite2-db and
# tkrs/maxmind-geoipupdate by Takeru Sato.
############################################################
FROM alpine
MAINTAINER Tom Callahan <[email protected]>
### DOWNLOAD DATABASES
ENV GEOIP_BASE_URL https://download.db-ip.com/free
ENV GEOIP_CNTR_DB dbip-country-lite-2020-08.mmdb
ENV GEOIP_CITY_DB dbip-city-lite-2020-08.mmdb
ENV GEOIP_DB_DIR /usr/share/GeoIP
ENV GEOIPUPDATE_VER "4.0.6"
# download gzip database files to /tmp/
ADD ${GEOIP_BASE_URL}/${GEOIP_CNTR_DB}.gz /tmp/
ADD ${GEOIP_BASE_URL}/${GEOIP_CITY_DB}.gz /tmp/
# unzip databases into database directory
RUN mkdir -p ${GEOIP_DB_DIR} \
&& gunzip -c /tmp/${GEOIP_CNTR_DB}.gz > ${GEOIP_DB_DIR}/${GEOIP_CNTR_DB} \
&& gunzip -c /tmp/${GEOIP_CITY_DB}.gz > ${GEOIP_DB_DIR}/${GEOIP_CITY_DB} \
&& rm -f /tmp/GeoLite2-*
VOLUME ${GEOIP_DB_DIR}
### INSTALL GEOIPUPDATE
# copy geoipupdate settings
COPY GeoIP.conf /usr/etc/GeoIP.conf
# install geoipupdate
RUN BUILD_DEPS='gcc make libc-dev libtool automake autoconf git' \
&& apk --no-cache add curl-dev ${BUILD_DEPS} \
&& apk update \
&& apk add ca-certificates \
&& update-ca-certificates \
&& apk add openssl \
&& wget -O /tmp/geoipupdate.tgz https://github.com/maxmind/geoipupdate/releases/download/v${GEOIPUPDATE_VER}/geoipupdate_${GEOIPUPDATE_VER}_linux_amd64.tar.gz \
&& tar -zxpvf /tmp/geoipupdate.tgz -C /opt/ \
&& cp /opt/geoipupdate_${GEOIPUPDATE_VER}_linux_amd64/geoipupdate /usr/bin/geoipupdate \
&& apk del --purge ${BUILD_DEPS} \
&& rm -rf /var/cache/apk/* \
&& rm -rf /tmp/geoipupdate.tgz \
&& rm -rf /opt/geoipupdate_${GEOIPUPDATE_VER}_linux_amd64
### CONFIGURE AUTOMATIC UPDATES
# copy crontab for running updates
COPY cronfile /var/spool/cron/crontabs/root
# run crond in foreground
ENTRYPOINT ["crond", "-f"]
# set crond options: log to stderr with log level 8
CMD ["-d", "8"]