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/

Self-hosting Sentry With Docker and Docker-compose的更多相关文章

  1. .NET遇上Docker - 使用Docker Compose组织Ngnix和.NETCore运行

    本文工具准备: Docker for Windows Visual Studio 2015 与 Visual Studio Tools for Docker 或 Visual Studio 2017 ...

  2. Docker,Docker Compose,Docker Swarm,Kubernetes之间的区别

    Dcoker Docker 这个东西所扮演的角色,容易理解,它是一个容器引擎,也就是说实际上我们的容器最终是由Docker创建,运行在Docker中,其他相关的容器技术都是以Docker为基础,它是我 ...

  3. 物联网架构成长之路(24)-Docker练习之Compose容器编排

    0.前言 一开始学的之后,是想一步到位直接上Kubernetes(K8s)的,后面没想到,好像有点复杂,有些概念不是很懂.因此学习东西还是要循序渐进,慢慢来.先了解单机编排技术Docker Compo ...

  4. docker和docker compose常用操作命令

    首先区分一下docker中几个概念 Image:镜像,相当于一个root文件系统,不包含任何动态数据 Container:容器,镜像运行时的实体,实质是进程,容器进程运行于属于自己的独立的命名空间 d ...

  5. Docker 0x13: Docker 构建集群/服务/Compose/分布式服务栈

    目录 Docker 构建集群/服务/Compose/分布式服务栈 集群 初始化集群服务 安装docker-machine 管理节点和工作节点 docker集群构建完成 集群中部署应用 集群服务访问特性 ...

  6. docker swarm和compose 的使用(阿里)

    基本的docker使用参考:Docker 入门 到部署Web 程序- (阿里面试常用的docker命令和优点) 昨天去阿里面试 问我如果给你5台服务器 如何部署docker,我说一个个拷贝,面试官听了 ...

  7. Dockerfile & Docker Swarm & Docker Stack & Docker Compose

    Dockerfile 通俗地讲,它是为了指导单个镜像从无到有的构建过程.如果你镜像是从Docker registry上面拉下来的,那就用不到这个文件:如果你是自己的应用,想打包成镜像,那就需要这个文件 ...

  8. linux安装docker和docker compose

    运行 sudo -s 切换到root用户. 1.卸载旧版本Docker(如果系统之前没安装过Docker,可以跳过): yum remove docker \ docker-client \ dock ...

  9. docker和docker compose安装使用、入门进阶案例

    一.前言 现在可谓是容器化的时代,云原生的袭来,导致go的崛起,作为一名java开发,现在慌得一批.作为知识储备,小编也是一直学关于docker的东西,还有一些持续继承jenkins. 提到docke ...

  10. [Docker基础]Docker安装教程

    Install Docker Docker支持几乎所有的Linux发行版,也支持Mac和Windows. 各操作系统的安装方法可参考Docker官网. 安装环境 ubuntu 16.04 Docker ...

随机推荐

  1. 【转载】深入理解Java的接口和抽象类

    深入理解Java的接口和抽象类 对于面向对象编程来说,抽象是它的一大特征之一.在Java中,可以通过两种形式来体现OOP的抽象:接口和抽象类.这两者有太多相似的地方,又有太多不同的地方.很多人在初学的 ...

  2. 无需编写代码,API业务流程测试,零代码实现

    引言 除了测试单个接口,我们常常需要对多个有数据或者逻辑关联的接口进行业务流程测试,例如获取验证码-注册-登录.传统测试业务流程需要编写一系列测试代码,现在通过eoLinker全UI界面,无需编写任何 ...

  3. HDU 2268 How To Use The Car (数学题)

    题目 //做起来很艰辛,总结起来很简单... //注意步行速度可能比车的速度快.... //推公式要仔细,,,, //一道对我来说很搞脑子的数学题,,,,, //车先送第一个人上路,第二个人步行:中途 ...

  4. 回文词(Palindromes, UVa401)

    输入一个字符串,判断它是否为回文串以及镜像串.输入字符串保证不含数字0. 所谓 回文串,就是反转以后和原串相同,如abba和madam. 所谓镜像串,就是左右镜像之后和原串相同,如2S和3AIAE. ...

  5. 多重循环、缓冲区管理、数组(day06)

    无法预知的数字叫随机数 rand标准函数可以用来获得随机数 为了使用这个标准函数需要包含stdlib.h头文件 srand标准函数用来设置随机数种子 这个函数把一个整数作为种子使用 不同的种子产生的随 ...

  6. BZOJ 2006 [NOI2010]超级钢琴 (堆+主席树)

    题面:BZOJ传送门 洛谷传送门 让你求前$K$大的子序列和,$n\leq 5*10^{5}$ 只想到了个$nlog^{2}n$的做法,似乎要被卡常就看题解了.. 好神奇的操作啊,我傻了 我们把序列和 ...

  7. Codeforces 851B/C

    B. Arpa and an exam about geometry 传送门:http://codeforces.com/contest/851/problem/B 本题是一个平面几何问题. 平面上有 ...

  8. workspace 配置

    1.新建workspace 在配置好相关信息前,请勿引入工程代码,避免环境不完整的情况下编译进入长时间等待 2.设置工作窗体结构 建议使用Java模式开发窗体设置 3. 编码 工程全部采用UTF-8编 ...

  9. luogu P4726 多项式指数函数(模板题FFT、多项式求逆、多项式对数函数)

    手动博客搬家: 本文发表于20181127 08:39:42, 原地址https://blog.csdn.net/suncongbo/article/details/84559818 题目链接: ht ...

  10. 0622centos下coreseek安装及使用方法

    Coreseek 中文全文检索引擎 Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索.论坛 ...