Sentry is a robust, open-source error-tracking application designed to identify issues in real-time. This guide details the step-by-step process to install Sentry using Docker on an Ubuntu 18.04 server.
Requirements
- A server running Ubuntu 18.04 with at least 4 GB of RAM.
- A root password configured on your server.
Getting Started
To ensure optimal performance and security, begin by updating your system to the latest version. Execute the following commands:
apt-get update -y apt-get upgrade -y
After updating, restart your system to apply the latest changes.
Installing Docker CE
As a first step, you’ll need to install Docker CE. The latest version isn’t present in Ubuntu 18.04’s default repositories, so you’ll have to add Docker’s official repository:
Start by installing the necessary packages:
apt-get install curl git build-essential apt-transport-https ca-certificates curl software-properties-common -y
Then, add Docker’s GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
Add the Docker CE repository:
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Finally, update your package repository and install Docker CE:
apt-get update -y apt-get install docker-ce -y
To verify Docker’s successful installation, check its status:
systemctl status docker
Expected output should indicate Docker is active and running:
? docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2019-07-03 12:34:40 UTC; 22s ago Docs: https://docs.docker.com Main PID: 4683 (dockerd) Tasks: 8 CGroup: /system.slice/docker.service ??4683 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock Jul 03 12:34:37 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:37.685945390Z" level=warning msg="Your kernel... Jul 03 12:34:40 ubuntu1804 dockerd[4683]: time="2019-07-03T12:34:40.230411944Z" level=info msg="API listen on /var/run/docker.sock"
Installing Sentry
Clone the latest Sentry version from the GitHub repository:
git clone https://github.com/getsentry/onpremise
Post-download, the output should display as follows:
Cloning into 'onpremise'... remote: Enumerating objects: 13, done. ...
Build the local custom image:
cd ~/onpremise make build
Create the Sentry service script with:
nano sentry_services.sh
Input these lines into the file:
#! /bin/bash clear docker run --detach --name sentry-redis redis:3.2-alpine docker run --detach --name sentry-postgres --env POSTGRES_PASSWORD=secret --env POSTGRES_USER=sentry postgres:9.5 docker run --detach --name sentry-smtp tianon/exim4 docker run --rm sentry-onpremise --help docker run --rm sentry-onpremise config generate-secret-key
Save and close the file, then execute:
. sentry_services.sh
The output will look like:
0kvhow&i+k#rjkkc0wvo*n=45=uuua8)51li8)cdjuld6e(2wa
Store the above key with:
echo 'export SENTRY_SECRET_KEY="0kvhow&i+k#rjkkc0wvo*n=45=uuua8)51li8)cdjuld6e(2wa"' >> ~/.bashrc source ~/.bashrc
Begin the migration process:
docker run --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} --rm -it sentry-onpremise upgrade
Once complete, start the Sentry application:
docker run --detach --name sentry-web-01 --publish 9000:9000 --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} sentry-onpremise run web
Initiate the background workers:
docker run --detach --name sentry-worker-01 --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} sentry-onpremise run worker
Start the cron service:
docker run --detach --name sentry-cron --link sentry-redis:redis --link sentry-postgres:postgres --link sentry-smtp:smtp --env SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY} sentry-onpremise run cron
Sentry is now operational, listening on port 9000. Access Sentry’s web interface at http://yourserverip:9000.
Congratulations! You have successfully installed and configured Sentry with Docker on your Ubuntu 18.04 server.
FAQ
What is Sentry used for?
Sentry is used for real-time error tracking, helping developers identify and fix issues in their applications promptly.
Why should I use Docker to install Sentry?
Docker simplifies deployment by providing containerized solutions that are portable and consistent across different platforms, reducing environmental discrepancies.
Can I run Sentry on a server with less than 4 GB RAM?
While possible, it is not recommended as Sentry’s performance may degrade without sufficient resources.