Umami: The Self-hosted Google Analytics Alternative
Google Analytics has become less and less fun to use over the years so I've been looking for a better, simpler tool which I could run on my own server and customize to my preferences. Umami seems to be the perfect tool for the job, offering basic site tracking and analytics in a tool you can run on your own server.
Here's how I set up Umami on my personal server using Docker and CapRover.
Create Wrapper Dockerfile
This part is optional since you could just use the One-click app install found in CapRover, but I often prefer to create my own Dockerfile fork in case I want to customize or tweak the product, or have direct control of the version being installed.
First I created a simple public (GitHub repo) for the wrapper, creating two files:
- Dockerfile:
FROM ghcr.io/umami-software/umami:postgresql-latest
RUN echo "Setting up umami"
# Expected ENV variables:
# DATABASE_URL: postgresql://umami:umami@db:5432/umami
# DATABASE_TYPE: postgresql
# APP_SECRET: replace-me-with-a-random-string
- This also lets me drop in notes about whan environment variables I should be passing in when running the app.
- captain-definition:
{
"schemaVersion": 2,
"dockerfilePath": "./Dockerfile"
}
Create New App in CapRover
Next up I log into my CapRover UI and Create New App using the name "umami". Then open the umami app to further edit its settings.
We need to set the container port to 3000 since we can see this is the port being used in Umami's Dockerfile.
On the App Configs tab we need to set three key/value pairs (Environment variables):
DATABASE_URL
should be a connection string likepostgresql://USERNAME:PASSWORD@IP_OR_HOSTNAME:5432/umami
, change as neededDATABASE_TYPE
should bepostgresql
ormysql
depending on your DB typeAPP_SECRET
should be a random string you create or generate. You can generate one using this bash shell snippet:head -c 32 /dev/urandom | base64 | head -c 32
Now click Save & Restart to apply the settings.
Run CapRover Deploy
On your local machine having installed the Caprover CLI, you would then run caprover deploy
in the same folder as the Wrapper Dockerfile created in the previous steps. It will ask to log in to your caprover machine and choose the Umami app to deploy it.
Set Up Database
Before Umami can work you will need to at least create the database in your PostgreSQL or MySQL server. You must run this command:
CREATE DATABASE umami;
and that should be both postgresql and mysql compatible.
Once you do that Umami will detect an empty database and create the necessary tables automatically.
Change Umami Password
This part you should do as quickly as possible: Visit your umami URL which will be something like http://umami.rootsubdomain.rootdomain.net/
Enter the default username and password which is admin
and umami
. As soon as you're in, visit the /profile
URL immediately and
click Change Password. Set a long secure password to protect your instance.
Now you're ready to start using Umami! You can continue reading docs on their website for more info.
Happy hacking!
This article, and all articles on this blog, were written without the use of any AI, GPT, or Language Learning Models. It's old fashioned I guess.