Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active February 25, 2025 13:24
Show Gist options
  • Select an option

  • Save gmolveau/78f88af3f5951ba6e093f93a07caa302 to your computer and use it in GitHub Desktop.

Select an option

Save gmolveau/78f88af3f5951ba6e093f93a07caa302 to your computer and use it in GitHub Desktop.
How to push Fathom analytics - https://github.com/usefathom/fathom to Heroku

Fathom on Heroku

  • heroku cli + git + curl + wget + tar are required

  • openssl is required to generate the secret_key, but you can change to something else

  • create the app via the buildpack

heroku create UNIQUE_APP_NAME --buildpack https://github.com/ph3nx/heroku-binary-buildpack.git
  • locally clone the newly created app
heroku git:clone -a UNIQUE_APP_NAME
cd UNIQUE_APP_NAME
  • create the folder that will contain our binary
mkdir -p bin
  • download latest version of fathom
curl -s https://api.github.com/repos/usefathom/fathom/releases/latest \
  | grep browser_download_url \
  | grep linux_amd64.tar.gz \
  | cut -d '"' -f 4 \
  | wget -qi - -O- \
  | tar --directory bin -xz - fathom
  • create the Procfile for heroku
echo "web: bin/fathom server" > Procfile
  • create a Postgres database
heroku addons:create heroku-postgresql:hobby-dev
  • update the environment variables, generate a secret_key
heroku config:set PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/bin \
  FATHOM_DATABASE_DRIVER=postgres \
  FATHOM_DATABASE_URL=$(heroku config:get DATABASE_URL) \
  FATHOM_DEBUG=true \
  FATHOM_SECRET= $(openssl rand -base64 32) \
  FATHOM_GZIP=true
  • add, commit and push all our files
git add --all
git commit -m "First Commit"
git push heroku master

heroku ps:scale web=1

heroku dyno:resize hobby
  • check if everything works
heroku run fathom --version
  • add the first user
heroku run fathom user add --email="test@test.com" --password="test_password"
  • open the browser to connect and create your first website
heroku open
  • ENJOY :)
@andrewpmiller
Copy link

This is awesome! Thank you!
One minor correction: The command to setFATHOM_SECRET has an errant space before the $
This works: FATHOM_SECRET=$(openssl rand -base64 32) \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment