Server Environment: VPS, Discourse deployed via Docker in 1Panel
This solution applies when maxmind ID and key are not set in app.yml, and GeoLite2-City.mmdb and GeoLite2-ASN.mmdb are automatically downloaded on a regular schedule via a GitHub mirror.
This resolves the following two MaxMindDB warnings found in the error logs:
MaxMindDB (/var/www/discourse/vendor/data/GeoLite2-City.mmdb) could not be found: No such file or directory @ rb_sysopen - /var/www/discourse/vendor/data/GeoLite2-City.mmdb
MaxMindDB (/var/www/discourse/vendor/data/GeoLite2-ASN.mmdb) could not be found: No such file or directory @ rb_sysopen - /var/www/discourse/vendor/data/GeoLite2-ASN.mmdb
Procedure:
1. Create the maxmind directory on the host machine and set permissions
mkdir -p /opt/1panel/apps/discourse/shared/standalone/maxmind && chmod 755 /opt/1panel/apps/discourse/shared/standalone/maxmind && chown 1000:1000 /opt/1panel/apps/discourse/shared/standalone/maxmind
2. Configure mounting of GeoLite2-City.mmdb and GeoLite2-ASN.mmdb files to the host as follows:
Edit app.yml and add:
- volume:
host: /opt/1panel/apps/discourse/shared/standalone/maxmind/GeoLite2-City.mmdb
guest: /var/www/discourse/vendor/data/GeoLite2-City.mmdb
- volume:
host: /opt/1panel/apps/discourse/shared/standalone/maxmind/GeoLite2-ASN.mmdb
guest: /var/www/discourse/vendor/data/GeoLite2-ASN.mmdb
3. Set up a scheduled task in 1Panel to regularly download and update the GeoLite2-City.mmdb and GeoLite2-ASN.mmdb map files from GitHub on a weekly basis
The scheduled task script is as follows:
cd /opt/1panel/apps/discourse/shared/standalone/maxmind && rm -f GeoLite2-City.mmdb GeoLite2-ASN.mmdb && wget -O GeoLite2-City.mmdb https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-City.mmdb && wget -O GeoLite2-ASN.mmdb https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-ASN.mmdb && chmod 644 GeoLite2-City.mmdb GeoLite2-ASN.mmdb && chown 1000:1000 GeoLite2-City.mmdb GeoLite2-ASN.mmdb
