Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lite geonames by default #2214

Merged
merged 1 commit into from
Oct 4, 2022
Merged

Conversation

ruslandoga
Copy link
Contributor

@ruslandoga ruslandoga commented Sep 12, 2022

👋

Right now the container image contains a large geonames.csv file that makes self-hosting difficult on small instances as it requires additional ~700MB of RAM and slows down plausible container startup.

This PR makes geonames.csv to not be included in the final container image. geonames.csv or a similar file can still be separately mounted in a volume for the same end result.

Container image with this change: ghcr.io/ruslandoga/analytics:pr-1


Something like the following could be added to docs for self-hosters:

If more accurate city-level tracking is desired, it should be enabled by mounting a volume with downloaded s3://geonames.csv and setting GEONAMES_SOURCE_FILE to point to it:

+ curl -O https://s3.eu-central-1.wasabisys.com/plausible-application/geonames.csv
# based on https://github.com/plausible/hosting/blob/f7682057104671b42e3fff3a106f93a32ea14775/docker-compose.yml#L27-L38
  plausible:
    image: ghcr.io/ruslandoga/analytics:pr-1 # works for both arm and x86 archs
    restart: always
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - plausible_db
      - plausible_events_db
      - mail
    ports:
      - 8000:8000
    env_file:
      - plausible-conf.env
+   # mounts the downloaded geonames.csv
+   # note that using geonames.csv would require additional ~700MB RAM
+   volumes:
+     - ./geonames.csv:/etc/app/geonames.csv:ro
# based on https://github.com/plausible/hosting/blob/f7682057104671b42e3fff3a106f93a32ea14775/plausible-conf.env
ADMIN_USER_EMAIL=replace-me
ADMIN_USER_NAME=replace-me
ADMIN_USER_PWD=replace-me
BASE_URL=replace-me
SECRET_KEY_BASE=replace-me
+ # adds GEONAMES_SOURCE_FILE env var pointing to the mounted `geonames.csv`
+ # note that using geonames.csv would require additional ~700MB RAM
+ GEONAMES_SOURCE_FILE=/etc/app/geonames.csv 

Below you'll find a checklist. For each item on the list, check one option and delete the other.

Tests

  • This PR does not require tests

Changelog

  • This PR does not make a user-facing change

Documentation

  • Docs have been updated

Dark mode

  • This PR does not change the UI

@bundlemon
Copy link

bundlemon bot commented Sep 12, 2022

BundleMon

Unchanged files (7)
Status Path Size Limits
static/css/app.css
515.19KB -
static/js/dashboard.js
295.57KB -
static/js/app.js
12.13KB -
static/js/embed.host.js
5.58KB -
static/js/embed.content.js
5.06KB -
tracker/js/plausible.js
748B -
static/js/applyTheme.js
314B -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@ruslandoga ruslandoga marked this pull request as ready for review September 12, 2022 13:33
@ukutaht ukutaht merged commit bac3c3e into plausible:master Oct 4, 2022
@ruslandoga ruslandoga deleted the lite-geonames branch October 4, 2022 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants