基於docker-compose搭建本地sentry服務

環境要求:

  • 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: '[email protected]' mail.password: 'xxxx' mail.use-tls: false #The email address to send on behalf of mail.from: '[email protected]'

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章