我对将 Sentry 转换为 Docker 的方法
Since Sentry now officially supports installation via Docker - this repository will no longer be updated.
More info on Sentry's Docker installation https://docs.sentry.io/server/installation/docker/.
Latest changes introduced some new build tags:
if you want to keep your builds same as before update your Dockerfiles and change
FROM slafs/sentry to FROM slafs/sentry:6.4.
This is my approach for running Sentry inside Docker.
Almost everything here is configurable via environment variables (including DATABASES and CACHES settings).
It can be easily configured to run with redis (cache, buffers and celery broker), postgres database, LDAP and REMOTE_USER authentication backends.
to run a Sentry instance with default settings (with sqlite, locmem cache and no celery) run:
docker run -d --name=sentry --volume=/tmp/sentry:/data -p 80:9000 -e SECRET_KEY=randomvalue -e SENTRY_URL_PREFIX=http://sentry.mydomain.com slafs/sentry
You can visit now http://sentry.mydomain.com (assuming sentry.mydomain.com
is mapped to your docker host) and login with default credentials
(username admin and password admin) and create your first team and project.
Your sqlite database file and gunicorn logs are available in /tmp/sentry directory.
Try not to fork this repo just to create your own Docker image with some minor tweak. Please open an issue on GitHub and maybe we can include your use case directly within this image :).
You can even write a test case for your feature ;). See CONTRIBUTING.md.
Also feel free to give feedback and comments about this image in general.
Copy the file with environment variables environment.example e.g cp environment.example environment
and after tweaking some values run sentry like this
docker run -d --name=sentry --volume=/tmp/sentry:/data -p 80:9000 --env-file=environment slafs/sentry
ENTRYPOINT for this image is a little wrapper script around default sentry executable.
Default CMD is start which runs upgrade command (initializes and upgrades the database)
and creates a default administrator (superuser) and then runs a http service (as in sentry --config=... start).
All commands and args are passed to the sentry executable. This means
docker run [docker options] slafs/sentry --help
refers to running:
sentry --config=/conf/sentry.conf.py --help
inside the container.
You can specify a username, password and email address to create an initial sentry administrator.
Add those variables to your environment file
SENTRY_ADMIN_USERNAME=slafs
SENTRY_ADMIN_PASSWORD=mysecretpass
[email protected]
See django docs for details about createsuperuser command.
The default administrator username is admin with password admin (and root@localhost as email adress).
It is recommended to run your sentry instance with PostgreSQL database. To link your sentry instance with a postgres container you can do it like this:
docker pull postgres (if you haven't already).docker run -d --name=postgres_container postgres.DATABASE_URL=postgres://postgres:@postgresdb/postgres to environment file. docker run -d --name=sentry --volume=/tmp/sentry:/data -p 80:9000 --env-file=environment --link=postgres_container:postgresdb slafs/sentryNotice that an alias for your linked postgres container (postgresdb) is the same as a postgres host in DATABASE_URL variable.
DATABASE_URL is a value that is parsed by an external app called dj-database-url.
Redis container can be used to improve sentry performance in number of ways. It can be used as a:
You can link your sentry instance with a redis container like this:
docker pull redis (if you haven't already).docker run -d --name=redis_container redis
docker run -d --name=sentry --volume=/tmp/sentry:/data -p 80:9000 --env-file=environment --link=postgres_container:postgresdb --link=redis_container:redis slafs/sentry```
If you want to use a different container alias for redis you should add SENTRY_REDIS_HOST=your_redis_alias to environment file.
To use a redis cache backend add CACHE_URL=hiredis://redis:6379/2
(make sure you won't have a trailing / in this setting)
to environment file (where redis is the alias of your linked redis container).
See django-cache-url docs for available formats.
To use sentry update buffers
with redis you must add SENTRY_USE_REDIS_BUFFERS=True to environment file.
If you have many redis containers/hosts you can set a list of those hosts
in SENTRY_REDIS_BUFFERS variable so they can be used by sentry.
Like this: SENTRY_REDIS_BUFFERS=redis1:6380,redis2:6381.
See sentry docs for details about redis buffer.
To use Celery in sentry you must add CELERY_ALWAYS_EAGER=False to your environment file and run a celery worker like this:
docker run -d --name=sentry_celery_worker --link=redis_container:redis --link=postgres_container:postgresdb --volume=/tmp/sentry:/data --env-file=environment slafs/sentry celery worker -B
You can also set a different BROKER_URL via environment file by adding this:
SENTRY_BROKER_URL=redis://otherredishost:6379/1
You can run as many celery worker containers as you want but remember that only one of them should be run with -B option.
If you're using default values for CELERY_RESULT_SERIALIZER, CELERY_TASK_SERIALIZER
and CELERY_ACCEPT_CONTENT (default values support pickle)
you have to set C_FORCE_ROOT env var (to say 1)
to be able to run celery as a root user.
You can avoid this by setting those three to json.
Refer to Celery's serializer docs
for more info about security implications of using pickle as a task serialization format.
To have time-series data you must add
SENTRY_USE_REDIS_TSDB=True to the environment file.
By default Redis time-series storage will use the Redis connection
defined by SENTRY_REDIS_HOST and SENTRY_REDIS_PORT. Similarly
to configuring buffers, you can set SENTRY_REDIS_TSDBS to a list
of Redis servers: SENTRY_REDIS_TSDBS=redis1:6379,redis2:6380
You can configure all email settings
by environment variables with SENTRY_ prefix.
You have to also change an email backend and set it
to SENTRY_EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend or something similar.
With this image You should be able to easily configure LDAP authentication for your Sentry instance.
To enable it add SENTRY_USE_LDAP=True to your environment file.
Then set the needed options by adding env variables with LDAP_
prefix (see the table below). LDAP authentication backend is provided by
django-auth-ldap.
To enable authentication via REMOTE_USER, add SENTRY_USE_REMOTE_USER=True to your environment file.
See the AUTH_REMOTE_USER_* env variables below for further configuration.
Refer to sentry documentation, django documentation, celery documentation and django-auth-ldap documentation for the meaning of each setting.
| Environment variable name | Django/Sentry setting | Type | Default value | Description |
|---|---|---|---|---|
| SECRET_KEY | SECRET_KEY | REQUIRED! | set this to something random | |
| SENTRY_URL_PREFIX | SENTRY_URL_PREFIX | REQUIRED! | no trailing slash! | |
| DATABASE_URL | DATABASES | sqlite:////data/sentry.db | ||
| CACHE_URL | CACHES | locmem:// | ||
| CELERY_ALWAYS_EAGER | CELERY_ALWAYS_EAGER | bool | True | |
| SENTRY_BROKER_URL | BROKER_URL | redis://:/1 |
||
| CELERY_RESULT_SERIALIZER | CELERY_RESULT_SERIALIZER | pickle |
You may want change it to json. See http://docs.celeryproject.org/en/stable/configuration.html#celery-result-serializer |
|
| CELERY_TASK_SERIALIZER | CELERY_TASK_SERIALIZER | pickle |
You may want change it to json. See http://docs.celeryproject.org/en/stable/configuration.html#celery-task-serializer |
|
| CELERY_ACCEPT_CONTENT | CELERY_ACCEPT_CONTENT | list | pickle,json |
Comma separated values. You may want change it to json. See http://docs.celeryproject.org/en/stable/configuration.html#celery-accept-content |
| SENTRY_REDIS_HOST | redis | |||
| SENTRY_REDIS_PORT | int | 6379 | ||
| SENTRY_WEB_HOST | SENTRY_WEB_HOST | 0.0.0.0 | ||
| SENTRY_WEB_PORT | SENTRY_WEB_PORT |
暂无开放 Issues,或尚未同步最近议题。