Sentry is a neat little program to report crashes. And it's the only thing available for flutter. So how do you selfhost this without a nightmare ?
First of all: Sentry is ~32 Containers. And it likes to eat a lot of RAM for doing nothing. Because who doesn't need multiple time series databases - especially if all you wanted was crash reports.
Anyway I disgress, let's get it starting. All of this assumes debian 11. I won't cover the nginx/apache setup, only wrangling the docker compose stuff.
Clone sentry somewhere. Probably
sudo useradd sentry and then go to
/home/sentry and perform a
git clone https://github.com/getsentry/self-hosted.git
Now if you've done that, edit the
.env file as you like. My recommendation is to change the
Otherwise clickhouse will eat a lot of RAM for nothing, and your machine alerts might annoy you.
Now we need docker compose. If you have that, you just run
# allow user sentry to run docker compose commands sudo usermod -a -G docker sentry # run stuff as user sentry sudo -u sentry -g sentry bash # install things ./install.sh # start a test run inside the sentry user and setup prompted stuff docker compose up
I didn't use
-d here on purpose, kill it with
Ctrl + C if that works and let us automate this.
To automate the startup and updates, we want a new service file:
# /etc/systemd/system/sentry.service [Unit] Description=Sentry Host Requires=docker.service After=docker.service network-online.target Wants=network-online.target [Service] User=sentry Group=sentry Type=oneshot RemainAfterExit=yes WorkingDirectory=/home/sentry/self-hosted # prevent prompts, not perfect but works ExecStartPre=/home/sentry/self-hosted/install.sh --report-self-hosted-issues --skip-commit-check --skip-user-creation ExecStart=/usr/bin/docker compose up -d --remove-orphans ExecReload=/usr/bin/docker compose up -d --remove-orphans ExecStop=/usr/bin/docker compose down [Install] WantedBy=multi-user.target
Reload the systemd daemon and start it:
sudo systemctl daemon-reload sudo systemctl start sentry
Afterwards you can check that it's running and check the logs:
sudo systemctl status sentry sudo journalctl -u sentry -e
If you see something like
install.sh: cp: cannot create regular file 'postgres/wal2json/wal2json.so': Permission denied
Then make sure that
/home/sentry is fully owned by the sentry user:
sudo chown -R sentry:sentry /home/sentry
If all of this works, enable this for the next boot:
sudo systemctl enable sentry
All of this is fine, but unless you auto-restart your VM every couple days, you might wanna restart this. Systemd timers to the rescue.
Let's create a restart unit:
# /etc/systemd/system/sentry_restart.service [Unit] Description=Sentry restart Requires=docker.service Wants=network-online.target After=docker.service network-online.target [Service] Type=oneshot ExecStart=/bin/systemctl restart sentry
And a timer unit to run this job:
# /etc/systemd/system/sentry_restart.timer [Timer] # or choose any other time frame for restarts OnCalendar=weekly [Install] WantedBy=timer.target
Now enable it we run
sudo systemctl enable sentry_restart.timer sudo systemctl start sentry_restart.timer
The gist is to run the installer.sh, run sentry once for the manual stuff and then automate it via systemd units and a restart timer. Also you can't skip the install.sh, running docker compose pull + up will end in tears.