Skip to content

Commit ce6a11e

Browse files
committed
Add GeoIP database to base image with download fallback
- Copy GeoLite2-Country.mmdb from iznik-server/install during build - Attempt fresh download if MaxMind credentials provided as build args - Fall back to bundled database if download fails or no credentials - Ensures GeoIP always available without runtime download delays
1 parent cf311ae commit ce6a11e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Dockerfile.base

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,25 @@ RUN go install github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0
7272
# Remove packages that conflict with our setup
7373
RUN apt-get update && apt-get remove -y apache2* sendmail* mlocate php-ssh2 || true && rm -rf /var/lib/apt/lists/*
7474

75+
# ============ GEOIP DATABASE ============
76+
# Copy fallback GeoIP database first, then try to download fresh version
77+
# This ensures we always have a working database even if MaxMind download limits are hit
78+
COPY iznik-server/install/GeoLite2-Country.mmdb /var/lib/GeoIP/GeoLite2-Country.mmdb
79+
ARG MAXMIND_ACCOUNT
80+
ARG MAXMIND_KEY
81+
RUN mkdir -p /var/lib/GeoIP \
82+
&& if [ -n "$MAXMIND_ACCOUNT" ] && [ -n "$MAXMIND_KEY" ]; then \
83+
echo "Attempting to download fresh GeoIP database..." \
84+
&& echo "AccountID $MAXMIND_ACCOUNT" > /etc/GeoIP.conf \
85+
&& echo "LicenseKey $MAXMIND_KEY" >> /etc/GeoIP.conf \
86+
&& echo "ProductIds GeoLite2-Country" >> /etc/GeoIP.conf \
87+
&& echo "DatabaseDirectory /var/lib/GeoIP" >> /etc/GeoIP.conf \
88+
&& (geoipupdate -v -f /etc/GeoIP.conf \
89+
&& echo "GeoIP database downloaded successfully" \
90+
|| echo "GeoIP download failed (likely rate limited) - using fallback database") \
91+
; else \
92+
echo "MaxMind credentials not provided - using fallback GeoIP database" \
93+
; fi
94+
7595
# Final cleanup
7696
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

0 commit comments

Comments
 (0)