How to Self-Host Sentry.io on AWS EC2

2021/05/013 min read
bookmark this
Responsive image

Table of Contents

  1. Introduction
  2. Setup EC2 Ubuntu
  3. Install Docker and Docker Compose
  4. Clone the Sentry Self-Hosted Repo
  5. Install Sentry and Create a New User
  6. Run Docker Compose
  7. Conclusion

Introduction

This blog shows how to self-host Sentry.io on an AWS EC2 instance.

Sentry.io provides a self-hosted solution and hosts the source code here. Based on the Sentry self-host requirements, you'll need to meet the following specifications. These requirements will probably change when a new version comes out, so double-check the requirements before setting up the instance.

  • Docker 19.03.6+

  • Compose 1.28.0+

  • 4 CPU Cores

  • 8 GB RAM

  • 20 GB Free Disk Space

Setup EC2 Ubuntu

Launch AWS EC2 Instance

Choose Ubuntu Server 20.04, Free Tier Eligible

Choose t2.medium

The requirement is 4 CPU cores, but it looks like a minimum of 2 CPUs works fine, so I chose t2.medium here.

Configure Instance Details

This blog does not cover setting up AWS VPC or subnets. Most of the settings here can be left as default, as long as the VPC has public access.

Add Storage

For storage, set the size to 25 GB.

Configure Security Group

Depending on how you want to host Sentry, this could vary. At a minimum, make sure ingress ports 80 and 22 are open — one for access from the internet and another for SSH into the instance.

Finish Creating the Instance

After finishing the EC2 instance creation for Ubuntu, SSH into the instance. After connecting, we'll perform the following tasks to install Docker.

Install Docker and Docker Compose

Setup the Repository

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Add Docker's Official GPG Key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Install Docker Compose on Linux

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply Executable Permissions to the Binary

sudo chmod +x /usr/local/bin/docker-compose

Reboot Ubuntu

Clone the Sentry Self-Hosted Repo

git clone https://github.com/getsentry/onpremise.git

Install Sentry and Create a New User

During the installation process, you will be asked to create a new account. Enter the email and password to create a new account. You'll use the email and password to log in later.

cd onpremise/
sudo ./install.sh

Run Docker Compose

This docker-compose command might take some time to finish everything, but once it completes, you should be able to access Sentry via the browser using the instance's IP address.

sudo docker-compose up -d

Conclusion

If everything works, when you navigate to the instance's IP address in your browser, you should see the Sentry.io login page. Enter the email and password you created earlier to log in.

References

  • Install Docker Engine on Ubuntu

  • Install Docker Compose

  • Self-Hosted Sentry nightly