-->

本地搭建Sentry-docker-compose

2020-02-18 00:45发布

 

环境安装

 

1. 环境要求:

centos 7
Docker 17.05.0+
Compose 1.19.0+
RAM 2400MB 

 

docker-compose 安装
curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
or
yum install python-pip
pip install docker-compose
or
$ curl -L --fail https://github.com/docker/compose/releases/download/1.24.1/run.sh > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

 

1. git拉取当前假定为 /data/sentry,并进入此目录。
git clone https://github.com/getsentry/onpremise.git
然后进入目录仓库目录,默认为 onpremise。
2. 安装前配置
cd onpremise/sentry
cp config.example.yml config.yml
修改 smtp 配置
# mail.backend: 'smtp' # Use dummy if you want to disable email entirely
mail.host: 'smtp.163.com'
mail.port: 25
mail.username: 'xxxx@163.com'
mail.password: 'xxxx'
mail.use-tls: false
#The email address to send on behalf of
mail.from: 'xxxx@163.com'

 

3. 直接运行 ./install.sh

中间过程创建 管理员账号密码

 

最后一步,使用 docker-compose 启动所有容器并提供服务:

 

docker-compose up -d
这时候使用 docker-compose ps 命令可以看到类似如下的容器列表:

 

Name Command State Ports
---------------------------------------------------------------------------------------
onpremise_base_1 /entrypoint.sh run web Up 9000/tcp
onpremise_cron_1 /entrypoint.sh run cron Up 9000/tcp
onpremise_memcached_1 docker-entrypoint.sh memcached Up 11211/tcp
onpremise_postgres_1 docker-entrypoint.sh postgres Up 5432/tcp
onpremise_redis_1 docker-entrypoint.sh redis ... Up 6379/tcp
onpremise_smtp_1 entrypoint.sh tini -- exim ... Up 25/tcp
onpremise_web_1 /entrypoint.sh run web Up 0.0.0.0:9000->9000/tcp
onpremise_worker_1 /entrypoint.sh run worker Up 9000/tcp
并使用浏览器访问 {ip}:9000,使用开始自己填写的管理员账号就可以登录后台。

 

4. 其他
如果需要改变主机服务端口,只需要修改 docker-compose.yml 文件的 web 容器配置,如改为本机的 8888 端口提供服务:

web:
extends: base
links:
- redis
- postgres
- memcached
- smtp
ports:
- '8888:9000'
可以按照需求将整个服务在 systemd 管理,docker-compose 的其他相关命令如下:

 

docker-compose up # 创建并启动容器,容器没有创建无法启动,同时最好用 -d 参数在后台启动
docker-compose stop # 停止服务
docker-compose start # 启动服务,需要用 up 创建容器并停止之后

 

修改了配置文件应用到docker镜像中:

 

修改config.yal
或者
修改sentry.conf.py,比如添加smtp配置:

 

复制代码
SENTRY_OPTIONS['mail.backend'] = 'smtp'
SENTRY_OPTIONS['mail.host'] = 'smtp.***.com'
SENTRY_OPTIONS['mail.password'] = '*******'
SENTRY_OPTIONS['mail.username'] = 'sentry@**.com'
SENTRY_OPTIONS['mail.port'] = 25
SENTRY_OPTIONS['mail.use-tls'] = False
复制代码
然后

 

docker-compose down(关闭删除容器)
docker-compose build (重新编译镜像)
docker-compose up -d (运行)

 

这样就ok了

 

补充:centos防火墙使用firewalld,直接关闭firewalld docker会启动报错,所以这里配置firewalld规则:
复制代码
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" port protocol="tcp" port="9000" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="需要访问的ip" accept"
firewall-cmd --permanent --zone=trusted --change-interface=docker0
firewall-cmd --permanent --zone=trusted --add-port=9000/tcp
firewall-cmd --add-port=9000/tcp --permanent

 


Updating Sentry
Updating Sentry using Compose is relatively simple. Just use the following steps to update. Make sure that you have the latest version set in your Dockerfile. Or use the latest version of this repository.

 

Use the following steps after updating this repository or your Dockerfile:

 

docker-compose build --pull # Build the services again after updating, and make sure we're up to date on patch version
docker-compose run --rm web upgrade # Run new migrations
docker-compose up -d # Recreate the services

 

标签: