Installing Sentry with Docker

Sentry is an open-source error tracking platform that provides complete app logic, deep context, and visibility across the entire stack in real time. For the first time, developers can fix bugs at every stage of the product lifecycle, well before users ever encounter a problem.
This tool will help us to know production errors before our users do not even notice a problem.
Stop talking so much and let´s open some terminals
For this installation I will use a VM instance of google cloud with these features:

Since we have our instance we are going to create a folder called sentry
$ sudo mkdir sentry
In the sentry folder we are going to clone the repository
$ cd sentry
$ git clone https://github.com/getsentry/onpremise
We have to enter the onpremise folder
$ cd onpremise
Let’s create a script inside this folder called installingSentryWithDocker1.sh
$ sudo nano installingSentryWithDocker1.sh#! / bin / bash
clear
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch = amd64] https://download.docker.com/linux/ubuntu \
$ (lsb_release -cs) \
stable "
sudo apt-get update
sudo apt-get install docker-ce
sudo make build
sudo docker run \
--detach \
--name sentry-redis \
redis:3.2-alpine
sudo docker run \
--detach \
--name sentry-postgres \
--env POSTGRES_PASSWORD = secret \
--env POSTGRES_USER = sentry \
postgres:9.5
sudo docker run \
--detach \
--name sentry-smtp \
tianon / exim4
sudo docker run \
--rm sentry-onpremise \
--help
sudo docker run \
--rm sentry-onpremise \
config generate-secret-key
Save and execute the script
$ sudo source installingSentryWithDocker1.sh
Sentry will generate a key which we will have to save in an environment variable called: SENTRY_SECRET_KEY
$ echo 'export SENTRY_SECRET_KEY = "xxxxxxx ......."' >> ~ / .bashrc
$ source ~ / .bashrc
$ echo $ SENTRY_SECRET_KEY
Let’s create a script inside this folder called installingSentryWithDocker2.sh
$ sudo nano installingSentryWithDocker2.shsudo 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 upgradesudo 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 websudo 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 workersudo 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
Save and execute the script
$ sudo source installingSentryWithDocker2.sh
Open your browser and place your ip external:9000

Now we will hide port 9000 with nginx

Install Nginx
$ sudo apt-get update
$ sudo apt-get install nginx
Adjust the Firewall
$ sudo ufw app list
You should get a listing of the application profiles:
OutputAvailable applications:Nginx FullNginx HTTPNginx HTTPSOpenSSH
1)Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
2)Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
3)Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
In this guide, we will only need to allow traffic on port 80. You can enable this by typing:
$ sudo ufw allow 'Nginx HTTP'
You can verify the change by typing:
$ sudo ufw status
You should see HTTP traffic allowed in the displayed output
OutputStatus: activeTo Action From-- ------ ----OpenSSH ALLOW AnywhereNginx HTTP ALLOW AnywhereOpenSSH (v6) ALLOW Anywhere (v6)Nginx HTTP (v6) ALLOW Anywhere (v6)
Check your Web Server
$ systemctl status nginxOutput● nginx.service - A high performance web server and a reverse proxy serverLoaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)Active: active (running) since Mon 2016-04-18 16:14:00 EDT; 4min 2s agoMain PID: 12857 (nginx)CGroup: /system.slice/nginx.service├─12857 nginx: master process /usr/sbin/nginx -g daemon on; master_process on└─12858 nginx: worker process
You can access the default Nginx landing page to confirm that the software is running properly. You can access this through your server’s domain name or IP address

Now let’s go to our terminal and look for the nginx folder process on
$ cd etc$ cd nginx
Then we enter the sites-available folder
$ cd sites-available
Now let’s modify our default file
$ sudo nano default
We delete everything you have and paste this configuration
server {
listen 80 default_server;
server_name sentry.mysentry.com;
location / {
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
We are going to update our changes
$ sudo systemctl restart nginx
Ready we can access our sentry without port 9000.