observabilitystack / geoip-api

A JSON REST API for Maxmind GeoIP databases
https://observabilitystack.org
Apache License 2.0
35 stars 12 forks source link

Auto update #165

Open cyril94440 opened 8 months ago

cyril94440 commented 8 months ago

Hi there,

Why not implement auto-update from within the container instead of weekly releases?

Thanks

stouch commented 5 months ago

It'd be great indeed.

This is how we made it:


# For Debian:

wget --quiet https://github.com/maxmind/geoipupdate/releases/download/v6.1.0/geoipupdate_6.1.0_linux_amd64.deb -O geoipupdate_6.1.0_linux_amd64.deb
sudo dpkg -i ./geoipupdate_6.1.0_linux_amd64.deb
sudo nano /etc/GeoIP.conf

######
# `AccountID` is from your MaxMind account.
AccountID <ACCOUNT ID>

# `LicenseKey` is from your MaxMind account
LicenseKey <LICENSE KEY>

# `EditionIDs` is from your MaxMind account.
EditionIDs GeoLite2-ASN GeoLite2-City GeoLite2-Country
######

sudo geoipupdate 
# now files are under: /usr/share/GeoIP

# -> finally, setup a cron with root user:
#     0 10 * * 6,4 geoipupdate

# we can then use /usr/share/GeoIP/** files for docker image:
#  geoip:
#    image: ghcr.io/observabilitystack/geoip-api:latest
#    ports:
#      - 8080:8080
#    volumes:   
#      - /usr/share/GeoIP:/GeoIPDB 
#    environment:
#      - CITY_DB_FILE=/GeoIPDB/GeoLite2-City.mmdb
#      - ASN_DB_FILE=/GeoIPDB/GeoLite2-ASN.mmdb

# and auto-restart the container every x days with a cron:
#     0 30 * * 6,4 cd /path/to/dockercompose && docker-compose down geoip && docker-compose up -d geoip