Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

added maxmindinc/geoipupdate container to self-hosted docker setup (#249)

Samuel Philippb29afdeb9257
diff --git a/HOSTING.md b/HOSTING.md
index 975a1edf19..ca512b165e 100644
--- a/HOSTING.md
+++ b/HOSTING.md
@@ -185,6 +185,10 @@ to get country data for your analytics, you need to create an account and downlo
Once you have the database, mount it on the Plausible docker image and configure the path of the database file:
- GEOLITE2_COUNTRY_DB (*String*)
+To make this as easy as possible you can use the [`maxmindinc/geoipupdate`](https://hub.docker.com/r/maxmindinc/geoipupdate) Docker image.
+You just need to add your account details, mount the database in the `plausible` container and let the image update the database automatically.
+To run the complete setup including geoip see [`docker-compose-geoip.yml`](docker-compose-geoip.yml#L35).
+
If the Geolite database is not configured, no country data will be captured.
### External Services
diff --git a/docker-compose-geoip.yml b/docker-compose-geoip.yml
new file mode 100644
index 0000000000..2237cb59b5
--- /dev/null
+++ b/docker-compose-geoip.yml
@@ -0,0 +1,91 @@
+# NOTE:
+# This Docker-compose file is created as a sample and should not be used directly for production
+# You can adjust the settings as-per your environment
+version: "3.3"
+services:
+ # As it says, this service is a fake smtp server which accepts SMTP connections
+ # the inbox is available at localhost:8025, in actuality, you need to use a proper smtp server
+ fake_smtp:
+ image: mailhog/mailhog:v1.0.0
+ ports:
+ - 1025:1025
+ - 8025:8025
+ healthcheck:
+ test: echo | telnet 127.0.0.1 1025
+
+ plausible_db:
+ image: postgres:12
+ command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]
+ volumes:
+ - db-data:/var/lib/postgresql/data
+ environment:
+ - POSTGRES_PASSWORD=postgres
+ - POSTGRES_DB=plausible_db
+ - POSTGRES_USER=postgres
+ ports:
+ - 5432:5432
+
+ plausible_events_db:
+ image: yandex/clickhouse-server:latest
+ volumes:
+ - event-data:/var/lib/clickhouse
+ ports:
+ - 8123:8123
+
+ # optional, if you want to setup a geoip database and let it update automatically
+ # this requires an account at maxmind.com (https://www.maxmind.com/en/geolite2/signup)
+ geoip:
+ image: maxmindinc/geoipupdate
+ environment:
+ - GEOIPUPDATE_ACCOUNT_ID=<your-account-id>
+ - GEOIPUPDATE_LICENSE_KEY=<your-license-key>
+ - GEOIPUPDATE_EDITION_IDS=GeoLite2-Country
+ # update every 7 days
+ - GEOIPUPDATE_FREQUENCY=168
+ volumes:
+ - geoip:/usr/share/GeoIP
+
+ plausible:
+ build:
+ context: .
+ dockerfile: ./Dockerfile
+ command: sh -c "sleep 10 && /entrypoint.sh db migrate && /entrypoint.sh run"
+ depends_on:
+ - plausible_db
+ - plausible_events_db
+ - fake_smtp
+ ports:
+ - 80:8080
+ links:
+ - plausible_db
+ - plausible_events_db
+ - fake_smtp
+ env_file:
+ - plausible-variables.sample.env
+ # only if you use the geioip container
+ volumes:
+ - geoip:/geoip:ro
+ environment:
+ -
+
+ setup:
+ build:
+ context: .
+ dockerfile: ./Dockerfile
+ command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin"
+ depends_on:
+ - plausible_db
+ - plausible_events_db
+ links:
+ - plausible_db
+ - plausible_events_db
+ env_file:
+ - plausible-variables.sample.env
+
+volumes:
+ db-data:
+ driver: local
+ event-data:
+ driver: local
+ geoip:
+ driver: local
diff --git a/docker-compose.yml b/docker-compose.yml
index 368bed9c0f..b521aef075 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -51,7 +51,8 @@ services:
- fake_smtp
env_file:
- plausible-variables.sample.env
-
+ environment:
+ - GEOLITE2_COUNTRY_DB=/geoip/GeoLite2-Country.mmdb
setup:
build: