├── supervisor-web.conf
├── supervisor-cron.conf
├── supervisor-smtp.conf
├── supervisor-redis.conf
├── supervisor-worker.conf
├── supervisor-postgres.conf
├── supervisor-memcached.conf
├── LICENSE
├── nginx-site
├── install.sh
└── README.md
/supervisor-web.conf:
--------------------------------------------------------------------------------
1 | [program:sentry-web]
2 | command = docker start -i sentry_web_1
3 | user = sentry
4 | stdout_logfile = /home/sentry/logs/web.log
5 | stderr_logfile = /home/sentry/logs/web.log
6 | autostart=true
7 | autorestart=true
8 | startsecs=10
9 | priority=1400
--------------------------------------------------------------------------------
/supervisor-cron.conf:
--------------------------------------------------------------------------------
1 | [program:sentry-cron]
2 | command = docker start -i sentry_cron_1
3 | user = sentry
4 | stdout_logfile = /home/sentry/logs/cron.log
5 | stderr_logfile = /home/sentry/logs/cron.log
6 | autostart=true
7 | autorestart=true
8 | startsecs=10
9 | priority=1600
--------------------------------------------------------------------------------
/supervisor-smtp.conf:
--------------------------------------------------------------------------------
1 | [program:sentry-smtp]
2 | command = docker start -i sentry_smtp_1
3 | user = sentry
4 | stdout_logfile = /home/sentry/logs/smtp.log
5 | stderr_logfile = /home/sentry/logs/smtp.log
6 | autostart=true
7 | autorestart=true
8 | startsecs=10
9 | priority=1300
--------------------------------------------------------------------------------
/supervisor-redis.conf:
--------------------------------------------------------------------------------
1 | [program:sentry-redis]
2 | command = docker start -i sentry_redis_1
3 | user = sentry
4 | stdout_logfile = /home/sentry/logs/redis.log
5 | stderr_logfile = /home/sentry/logs/redis.log
6 | autostart=true
7 | autorestart=true
8 | startsecs=10
9 | priority=1200
--------------------------------------------------------------------------------
/supervisor-worker.conf:
--------------------------------------------------------------------------------
1 | [program:sentry-worker]
2 | command = docker start -i sentry_worker_1
3 | user = sentry
4 | stdout_logfile = /home/sentry/logs/worker.log
5 | stderr_logfile = /home/sentry/logs/worker.log
6 | autostart=true
7 | autorestart=true
8 | startsecs=10
9 | priority=1500
--------------------------------------------------------------------------------
/supervisor-postgres.conf:
--------------------------------------------------------------------------------
1 | [program:sentry-postgres]
2 | command = docker start -i sentry_postgres_1
3 | user = sentry
4 | stdout_logfile = /home/sentry/logs/postgres.log
5 | stderr_logfile = /home/sentry/logs/postgres.log
6 | autostart=true
7 | autorestart=true
8 | startsecs=10
9 | priority=1000
--------------------------------------------------------------------------------
/supervisor-memcached.conf:
--------------------------------------------------------------------------------
1 | [program:sentry-memcached]
2 | command = docker start -i sentry_memcached_1
3 | user = sentry
4 | stdout_logfile = /home/sentry/logs/memcached.log
5 | stderr_logfile = /home/sentry/logs/memcached.log
6 | autostart=true
7 | autorestart=true
8 | startsecs=10
9 | priority=1100
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Michael Herrmann
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/nginx-site:
--------------------------------------------------------------------------------
1 | ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
2 | ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
3 |
4 | server {
5 | listen 80;
6 | server_name DOMAIN;
7 |
8 | location / {
9 | if ($request_method = GET) {
10 | rewrite ^ https://$host$request_uri? permanent;
11 | }
12 | return 405;
13 | }
14 | }
15 |
16 | server {
17 | listen 443 ssl;
18 | server_name DOMAIN;
19 |
20 | proxy_set_header Host $http_host;
21 | proxy_set_header X-Forwarded-Proto $scheme;
22 | proxy_set_header X-Forwarded-For $remote_addr;
23 | proxy_redirect off;
24 |
25 | # keepalive + raven.js is a disaster
26 | keepalive_timeout 0;
27 |
28 | # use very aggressive timeouts
29 | proxy_read_timeout 5s;
30 | proxy_send_timeout 5s;
31 | send_timeout 5s;
32 | resolver_timeout 5s;
33 | client_body_timeout 5s;
34 |
35 | # buffer larger messages
36 | client_max_body_size 5m;
37 | client_body_buffer_size 100k;
38 |
39 | location / {
40 | proxy_pass http://localhost:9000;
41 |
42 | add_header Strict-Transport-Security "max-age=31536000";
43 | }
44 | }
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Installs Sentry and all dependencies on a fresh Debian 9.
4 | # Installation requires 4GB of RAM. If you don't have that much,
5 | # increase the swap size. Running should be okay at 1 GB.
6 | # To start, copy all files to the server and invoke ./install.sh.
7 |
8 | # Error handling:
9 | set -e
10 | trap 'echo "Error on line $LINENO"' ERR
11 |
12 | # Change these values!
13 | DOMAIN=sentry.myapp.com
14 | GMAIL_USER=john@gmail.com
15 | GMAIL_PASSWORD=mypassword
16 | ADMIN_EMAIL=john@gmail.com
17 |
18 | if [ -z "$LC_ALL" ]; then
19 | echo 'Setting locale to avoid Perl warnings "Setting locale failed."'
20 | locale-gen en_US.UTF-8
21 | su -c "echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale"
22 | echo 'Shell restart required. Please log out and back in, then execute the script again.'
23 | exit
24 | fi
25 |
26 | apt-get update
27 | apt-get upgrade -y
28 |
29 | echo 'Installing docker...'
30 | apt-get install apt-transport-https dirmngr -y
31 | echo 'deb https://apt.dockerproject.org/repo debian-stretch main' >> /etc/apt/sources.list
32 | apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys F76221572C52609D
33 | apt-get update
34 | apt-get install docker-engine -y
35 |
36 | echo 'Installing docker-compose'
37 | # Some, but not all versions of Debian have curl pre-installed.
38 | # Make sure it is installed:
39 | apt-get install curl -y
40 | curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
41 | chmod +x /usr/local/bin/docker-compose
42 |
43 | echo 'Creating application user...'
44 | useradd --system --gid docker --shell /bin/bash -m sentry
45 |
46 | echo 'Cloning sentry-onpremise repository...'
47 | su -c 'git clone https://github.com/getsentry/onpremise.git sentry' - sentry
48 | su -c 'cd sentry && git checkout cd13427aa9a231b2b27c9fd14017d183cca52c1e' - sentry
49 |
50 | echo 'Updating Sentry config to use SSL...'
51 | sed -i 's/environment:/environment:\n SENTRY_USE_SSL: 1/g' /home/sentry/sentry/docker-compose.yml
52 |
53 | echo 'Updating Sentry config to use Gmail...'
54 | sed -i "s=image: tianon/exim4=image: tianon/exim4\n environment:\n GMAIL_USER: ${GMAIL_USER}\n GMAIL_PASSWORD: ${GMAIL_PASSWORD}=g" /home/sentry/sentry/docker-compose.yml
55 |
56 | echo 'Building Sentry...'
57 | su -c 'docker volume create --name=sentry-data' - sentry
58 | su -c 'docker volume create --name=sentry-postgres' - sentry
59 | su -c 'cd sentry && cp -n .env.example .env' - sentry
60 | su -c 'cd sentry && docker-compose build' - sentry
61 | su -c 'cd sentry && SENTRY_SECRET_KEY=`docker-compose run --rm web config generate-secret-key` && echo "SENTRY_SECRET_KEY=${SENTRY_SECRET_KEY}" > .env' - sentry
62 | su -c 'cd sentry && docker-compose run --rm web upgrade' - sentry
63 |
64 | echo 'Creating all necessary Docker containers...'
65 | su -c 'cd sentry && docker-compose up -d' - sentry
66 |
67 | echo 'Installing Lets Encrypt...'
68 | git clone https://github.com/letsencrypt/letsencrypt
69 |
70 | echo 'Generating SSL certificates...'
71 | letsencrypt/letsencrypt-auto --standalone --non-interactive --force-renew --email ${ADMIN_EMAIL} --agree-tos auth -d ${DOMAIN}
72 |
73 | echo 'Uninstalling Lets Encrypt...'
74 | rm -rf letsencrypt
75 |
76 | echo 'Creating Sentry log file directory...'
77 | su -c 'mkdir -p /home/sentry/logs' - sentry
78 |
79 | echo 'Setting up Nginx...'
80 | apt-get install nginx -y
81 | cp nginx-site /etc/nginx/sites-available/sentry
82 | sed -i "s/DOMAIN/${DOMAIN}/g" /etc/nginx/sites-available/sentry
83 | ln -s /etc/nginx/sites-available/sentry /etc/nginx/sites-enabled/sentry
84 | rm /etc/nginx/sites-enabled/default
85 | service nginx reload
86 |
87 | echo 'Installing Supervisor...'
88 | apt-get install supervisor -y
89 |
90 | echo 'Configuring Supervisor...'
91 | cp supervisor*.conf /etc/supervisor/conf.d/
92 |
93 | echo 'Updating Supervisor...'
94 | supervisorctl reread
95 | supervisorctl update
96 |
97 | echo "Rebooting. In a few minutes, you should be able to open https://${DOMAIN}"
98 | reboot
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sentry self-hosted
2 | [Sentry](https://sentry.io) is a popular error tracking solution.
3 | They have a free tier, but it is rather limited. Prices for the
4 | hosted tier currently start at $26/mo.
5 |
6 | This repository lets you set up a self-hosted instance of Sentry
7 | on
8 | [Linode](https://www.linode.com/?r=03c98ce370ba6c626d40c900c8f6f316ccb808f2),
9 | for only $5/mo. You need a (sub-)domain such as `sentry.example.com`.
10 | Installation is mostly automatic and takes a little over 30 minutes
11 | in total.
12 |
13 | ## 1. Create a Linode account
14 | If you don't already have one,
15 | [create a Linode account](https://www.linode.com/?r=03c98ce370ba6c626d40c900c8f6f316ccb808f2).
16 | Use the promo code **DOCS10** for a $10 credit.
17 |
18 | ## 2. Add a Linode
19 | [Create a Linode](https://manager.linode.com/linodes/add?group=) in
20 | Linode's Management interface. (If you haven't used them before:
21 | Linodes are simply private Linux servers.) For small projects, a
22 | Nanode for $5/mo is enough.
23 |
24 | ## 3. Update your DNS
25 | The Linode management interface should now show the IP of your
26 | server. Update your domain's DNS settings so a new `A` record points
27 | to this IP. Typically, you'd use a subdomain such as
28 | `sentry.myapp.com`.
29 |
30 | ## 4. Install Debian 9
31 | Open the management page for your new Linode. Click on *Rebuild* at
32 | the top. Select *Debian 9* as the image and pick a password. Click
33 | *Rebuild*.
34 |
35 | ## 5. Increase swap size (if necessary)
36 | Installing Sentry requires about 4GB of RAM. If you chose a Nanode
37 | instance above, it only has 1GB. Go to the main management page for
38 | your Linode. You should see two disks:
39 |
40 | * Debian 9 Disk
41 | * 256MB Swap Image
42 |
43 | First, click on *Edit* next to *Debian 9 Disk*. Reduce its size by
44 | 5GB. Once this process is complete, *In*crease the size of the Swap
45 | Image by 5GB.
46 |
47 | ## 6. Install Sentry
48 | Connect to your server via SSH. Clone this repository:
49 |
50 | apt-get update
51 | apt-get install git -y
52 | git clone https://github.com/mherrmann/sentry-self-hosted.git
53 |
54 | Use an editor such as `vi` to change the settings at the top of
55 | `install.sh`. Then, make the file executable and run it:
56 |
57 | cd sentry-self-hosted
58 | chmod +x install.sh
59 | ./install.sh
60 |
61 | The first time you do this, the script will ask you to log out and
62 | back in again. Do this but **don't yet run the script again**.
63 |
64 | Invoking `install.sh` for a second time takes about 30 minutes.
65 | We don't want this process to be interrupted in case your internet
66 | connection drops. So it is highly recommended to install the
67 | `screen` tool at this point. This keeps your terminal session alive
68 | in case there are problems with your internet.
69 |
70 | To install screen, log into the server and type the following:
71 |
72 | apt-get install screen -y
73 |
74 | Then, launch `screen`:
75 |
76 | screen
77 |
78 | This shows some information. Press ENTER. You are now in
79 | a virtual terminal session hosted by `screen`. Now execute
80 |
81 | cd sentry-self-hosted
82 | ./install.sh
83 |
84 | again. You can detach from this terminal session by pressing
85 | Ctrl+A followed by D. To attach to
86 | the session again (either because you detached from it or because
87 | your connection dropped), type `screen -r` on the command line.
88 |
89 | The installation will prompt you to create a super user at some
90 | point. Provide it with some values.
91 |
92 | Once the installation is complete, the server will automatically
93 | reboot. You can now log into it with the user credentials you
94 | created.
95 |
96 | ## 7. Decrease swap size
97 | Once installation is complete, it's a good idea to decrease the swap
98 | size again (in case you increased it). Just follow the same steps as
99 | in 5.
100 |
101 | ## 8. (Optional) enable backups
102 | Linode can automatically back up your server for an extra $2 per
103 | month. You can enable this in the management interface for your
104 | Linode.
105 |
106 | Enjoy!
107 |
--------------------------------------------------------------------------------