If a user encounters an error but you don’t know about, did it happen at all?

Sentry is one of the several options for error tracking across many platforms and languages. Sentry has a great free option for 10,000 errors per month and a single user, but they also offer a self-hosted option that is 100% free. This post aims to help you configure your own installation of Sentry using docker-compose.

Assumptions

I will start by assuming that you have Docker and docker-compose installed and working. It would also be great if you had some experience with both of these.

Instructions

For your convenience I am providing a zip with the 3 files I describe below. It cannot just be executed ‘as-is’ you must make the configuration changes described in this post. sentry_docker_3_2018.zip

Save the following file as docker-compose.yml. It tells docker what containers to create and what environment variables to use when running them. Fill in the missing portions. The containers are configured to save their data to /srv/sentry so you may need to create this path or choose a different path.

version: '3'

services:
# OPTIONAL: If you want to get emails from sentry include this docker container
smtp:
image: 'tianon/exim4:latest'
environment:
GMAIL_USER: 'GMAIL_USER@gmail.com'
GMAIL_PASSWORD: 'GMAIL_PASSWORD_OR_GMAIL_APP_PASSWORD' sentry-base:
image: 'sentry:latest'
container_name: sentry-base
restart: unless-stopped
depends_on:
- sentry-redis
- sentry-postgres
links:
- sentry-redis
- sentry-postgres
ports:
- 880:9000
env_file:
- sentry.env
volumes:
- /srv/sentry/sentry:/var/lib/sentry/files sentry-cron:
image: 'sentry:latest'
restart: unless-stopped
depends_on:
- sentry-base
links:
- sentry-redis
- sentry-postgres
command: "sentry run cron"
env_file:
- sentry.env
volumes:
- /srv/sentry/sentry:/var/lib/sentry/files sentry-worker:
image: 'sentry:latest'
depends_on:
- sentry-base
links:
- sentry-redis
- sentry-postgres
command: "sentry run worker"
env_file:
- sentry.env
volumes:
- /srv/sentry/sentry:/var/lib/sentry/files sentry-redis:
image: 'redis:latest'
sentry-postgres:
image: 'postgres:latest'
environment:
POSTGRES_USER: sentry
POSTGRES_PASSWORD: sentry
POSTGRES_DB: sentry
volumes:
- /srv/sentry/postgres:/var/lib/postgresql/data

Next, save the environment variables file as sentry.env and edit it as appropriate.

# OPTIONAL: Include if you're using email
SENTRY_EMAIL_HOST=smtp SENTRY_POSTGRES_HOST=sentry-postgres
SENTRY_DB_USER=sentry
SENTRY_DB_PASSWORD=sentry
SENTRY_REDIS_HOST=sentry-redis # OPTIONAL: If you want GitHub integration
GITHUB_APP_ID=#FILL ME IN
GITHUB_API_SECRET=#FILL ME IN
GITHUB_EXTENDED_PERMISSIONS=["repo"] # OPTIONAL: Include if Sentry is available over HTTPS
SOCIAL_AUTH_REDIRECT_IS_HTTPS=true
SENTRY_SECRET_KEY=

If you want to use GitHub integration follow the steps below, otherwise skip ahead.

GitHub Integration

Make a new GitHub OAuth application at this link and enter in an application name. The “Homepage URL” and “Authorization callback URL” should both be set to the web root of your new Sentry install, such as “https://sentry.io/”.

Copy the “Client ID” and “Client Secret” from GitHub and paste them into the sentry.env file described above as “GITHUB_APP_ID” and “GITHUB_API_SECRET” respectively.

If your Sentry will be accessible over HTTPS, include the optional environment variable “SOCIAL_AUTH_REDIRECT_IS_HTTPS”.

Bringing up the service for the first time

Automatic Script

Utilize the script below or manually type the commands to generate a new secret key, build the database, and start the service.

#!/bin/bash

# Generate a random secret key and put it into the environment variable file
sed -i "$ s/$/$(docker-compose run --rm sentry-base sentry config generate-secret-key)/" sentry.env # Run database migrations (build the database)
docker-compose run --rm sentry-base sentry upgrade --noinput # Startup the whole service
docker-compose up -d

Save this file as sentry-install.sh and then make it executable by running chmod +x sentry-install.sh. Next, run the file by doing ./sentry-install.sh. This file will write a new secret key to the sentry.env file, so it is important that it is named in that way and that there are no additional lines after the “SENTRY_SECRET_KEY=”.

Manually

To do this all manually, run

– docker-compose exec sentry-base sentry config generate-secret-key put the output into the sentry.env file as “SENTRY_SECRET_KEY”.

– Next, run docker-compose exec sentry-base sentry upgrade which will initialize the postgres database. This command will need to be run every time the Sentry docker image is updated.

– Finally, use docker-compose up -d to bring up the service.

If you ran the commands above manually, then you’re done. If you used the script however, the service is up but there is no administrator.

Create the Administrator Account

Use the following command to create the administrator.

docker-compose exec sentry-base sentry createuser --email YOUR_EMAIL --password YOUR_NEW_PASSWORD --superuser --no-input

from https://mikedombrowski.com/2018/03/self-hosting-sentry-with-docker-and-docker-compose/

最新文章

  1. jquer 基础篇 dom操作
  2. 【BZOJ-4668】冷战 并查集 + 按秩合并 + 乱搞
  3. [Android Rro] SDK JAR
  4. 初学者用div+css结构写网页的几个误区
  5. [Android Pro] 监听Blutooth打开广播
  6. UserSelector兼容
  7. 实现弹出收回菜单效果ios源码
  8. hdu 2460 poj 3694 (双联通+LCA)
  9. (转)C++笔记:面向对象编程基础
  10. KingbaseES的DBLink创建
  11. JDK1.8源码阅读系列之三:Vector
  12. appium实例编写(1)---以ContactsTest.apk 操作为例
  13. ●UVA 1608 Non-boring sequences
  14. Openjudge — 7624 山区建小学
  15. 【Dalston】【第七章】分布式链路跟踪(Sleuth)
  16. hihoCoder week15 最近公共祖先·二
  17. CSS表单设计
  18. mysql回滚日志
  19. 【转】Oozie4.2.0配置安装实战
  20. JavaScript操作XML工作记录

热门文章

  1. PAT_A1127#ZigZagging on a Tree
  2. Django基础(二)
  3. [luogu1627 CQOI2009] 中位数 (乱搞)
  4. try finnlay 总结
  5. ubuntu-ln命令
  6. LNMP编译安装(centos7+nginx1.9+mysql5.6+php5.5)
  7. 时间格式字符串转化为date和时间戳
  8. [ Javascript ] 内存泄露以及循环引用解析
  9. 监控sql运行时剩余时间
  10. Cookies操作类