简体   繁体   English

如何使用docker设置哨兵

[英]How to setup sentry with docker

I have found the official sentry image in dockerhub. 我在dockerhub找到了官方的哨兵图像 But the document is incomplete and I can't setup the environment step by step. 但是文档不完整,我无法一步一步地设置环境。

We have to setup the database container first but none of them tell how to setup it at first. 我们必须首先设置数据库容器,但它们都没有告诉我们如何设置它。 Specifically I don't know what are the username and password that sentry will use. 具体来说,我不知道哨兵将使用的用户名和密码是什么。

And I also get the following error when I run the sentry container: 当我运行sentry容器时,我也收到以下错误:

sudo docker run --name some-sentry --link some-mysql:mysql -d sentry
e888fcf2976a9ce90f80b28bb4c822c07f7e0235e3980e2a33ea7ddeb0ff18ce

sudo docker logs some-sentry
Traceback (most recent call last):
  File "/usr/local/bin/sentry", line 9, in <module>
    load_entry_point('sentry==6.4.4', 'console_scripts', 'sentry')()
  File "/usr/local/lib/python2.7/site-packages/sentry/utils/runner.py", line 310, in main
    initializer=initialize_app,
  File "/usr/local/lib/python2.7/site-packages/logan/runner.py", line 167, in run_app
    configure_app(config_path=config_path, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/logan/runner.py", line 89, in configure_app
    raise ValueError("Configuration file does not exist at %r" % (config_path,))
ValueError: Configuration file does not exist at '/.sentry/sentry.conf.py'

This is a moving target. 这是一个移动的目标。 I suggest checking https://hub.docker.com/_/sentry/ for updates as their documentation is pretty good. 我建议检查https://hub.docker.com/_/sentry/以获取更新,因为他们的文档非常好。

Circa version 8 you can easily convert those instructions to use docker-compose 大约8版,您可以轻松地将这些指令转换为使用docker-compose

docker-compose.yml 泊坞窗,compose.yml

version: "2"
services:
  redis:
    image: redis:3.0.7
    networks:
    - sentry-net

  postgres:
    image: postgres:9.6.1
    environment:
    - POSTGRES_USER:sentry
    - POSTGRES_PASSWORD:sentry
    # volumes:
    # - ./data:/var/lib/postgresql/data:rw
    networks:
    - sentry-net

  sentry:
    image: sentry:${SENTRY_TAG}
    depends_on:
    - redis
    - postgres
    environment:
    - SENTRY_REDIS_HOST=redis
    - SENTRY_SECRET_KEY=${SECRET}
    - SENTRY_POSTGRES_HOST=postgres
    ports:
    - 9000:9000
    networks:
    - sentry-net

  sentry_celery_beat:
    image: sentry:${SENTRY_TAG}
    depends_on:
    - sentry
    environment:
    - SENTRY_REDIS_HOST=redis
    - SENTRY_SECRET_KEY=${SECRET}
    - SENTRY_POSTGRES_HOST=postgres
    command: "sentry run cron"
    networks:
    - sentry-net

  sentry_celery_worker:
    image: sentry:${SENTRY_TAG}
    depends_on:
    - sentry
    environment:
    - SENTRY_REDIS_HOST=redis
    - SENTRY_SECRET_KEY=${SECRET}
    - SENTRY_POSTGRES_HOST=postgres
    command: "sentry run worker"
    networks:
    - sentry-net

networks:
  sentry-net:

.env .ENV

SENTRY_TAG=8.10.0

Run docker run --rm sentry:8.10.0 config generate-secret-key and add the secret 运行docker run --rm sentry:8.10.0 config generate-secret-key并添加秘密

.env updated .env更新

SENTRY_TAG=8.10.0
SECRET=somelongsecretgeneratedbythetool

First boot: 首次启动:

docker-compose up -d postgres
docker-compose up -d redis
docker-compose run sentry sentry upgrade

Full boot 完全启动

docker-compose up -d

Debug 调试

docker-compose ps
docker-compose logs --tail=10

Take a look at the sentry.conf.py file that is part of the official sentry docker image. 看看作为官方哨兵码头图像一部分的sentry.conf.py文件。 It gets a bunch of properties from the environment eg SENTRY_DB_NAME, SENTRY_DB_USER. 它从环境中获取了一堆属性,例如SENTRY_DB_NAME,SENTRY_DB_USER。 Below is an excerpt from the file. 以下是该文件的摘录。

os.getenv('SENTRY_DB_PASSWORD')
or os.getenv('MYSQL_ENV_MYSQL_PASSWORD')
or os.getenv('MYSQL_ENV_MYSQL_ROOT_PASSWORD')

So as for your question about how to sepcify database password it must be set in environment variables. 关于如何分类数据库密码的问题,必须在环境变量中设置。 You can do this by running: 你可以通过运行:

sudo docker run --name some-sentry --link some-mysql:mysql \
    -e SENTRY_DB_USER=XXX                                  \
    -e SENTRY_DB_PASSWORD=XXX                              \
    -d sentry

As for your issue with the exception you seem to be missing a config file Configuration file does not exist at '/.sentry/sentry.conf.py' That file is copied to /home/user/.sentry/sentry.conf.py inside the container. 至于您的异常问题,您似乎缺少配置文件Configuration file does not exist at '/.sentry/sentry.conf.py'该文件被复制到/home/user/.sentry/sentry.conf.py在容器内。 I am not sure why your sentry install is looking for it at /.sentry/sentry.conf.py. 我不知道你的哨兵安装为什么要在/.sentry/sentry.conf.py上找它。 There may be an environment variable or a setting that controls this or this may just be a bug in the container. 可能存在环境变量或控制此设置的设置,或者这可能只是容器中的错误。

This works for me https://github.com/slafs/sentry-docker and we don't have to setup database or others. 这适用于我https://github.com/slafs/sentry-docker ,我们不必设置数据库或其他人。 I will learn more about the configuration in detail later. 稍后我会详细了解配置。

Here my docker compose yml, with official image from https://hub.docker.com/_/sentry/ : 在这里,我的码头工作者使用来自https://hub.docker.com/_/sentry/的官方图片撰写yml:

https://gist.github.com/ebuildy/270f4ef3abd41e1490c1 https://gist.github.com/ebuildy/270f4ef3abd41e1490c1

Run: 跑:

docker-compose -p sw up -d
docker exec -ti sw_sentry_1 sentry upgrade

Thats it! 而已!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM