diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b23e8e2a55d4af8c1adbdc6fad355646262554d7..2a5569370138410b43035c346b79a1d374348af8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,7 @@ build docker image: - echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com script: - docker-compose config -q - - docker-compose build --build-arg install_dev_requirements=0 web + - docker-compose build --build-arg install_dev_requirements=0 --build-arg source_commit=$(git rev-parse HEAD) web - docker-compose run --rm web test - docker tag $DOCKER_LATEST $DOCKER_TAG - docker push $DOCKER_TAG diff --git a/Dockerfile b/Dockerfile index c9ebe149ebbad161db7d119249f35bcb92a46f71..f8ff92b93f94d9565ed54b1c19ec64aa8b98ae1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ LABEL description="Contains the Thaliawebsite Django application" # Arguments ARG install_dev_requirements=1 +ARG source_commit="unknown" # Try to keep static operation on top to maximise Docker cache utilisation @@ -11,6 +12,7 @@ ARG install_dev_requirements=1 ENV DJANGO_PRODUCTION 1 ENV PYTHONUNBUFFERED 1 ENV DEBIAN_FRONTEND=noninteractive +ENV SOURCE_COMMIT=${source_commit} # Set up entrypoint and command ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/requirements.txt b/requirements.txt index 83da67b1d26084d44a38547b02240693bc736d43..bfea39a465f95e7c504d34c6e8e4bd7c4a0f05df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,3 +16,4 @@ pyfcm>=1.4.2,<1.5 celery>=4.0<4.2 redis>=2.10<2.11 django-celery-results>=1.0.1<1.1 +raven>=6.4.0,<6.5.0 diff --git a/website/thaliawebsite/settings/production.py b/website/thaliawebsite/settings/production.py index 46f499f5cc20c6338fa1c911f3950e6b20e613a3..762c3b52ef8fea2cc0c1200555f11e6890e2bf5b 100644 --- a/website/thaliawebsite/settings/production.py +++ b/website/thaliawebsite/settings/production.py @@ -10,14 +10,11 @@ See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ """ import os -from copy import deepcopy - -from django.utils.log import DEFAULT_LOGGING from . import settings INSTALLED_APPS = settings.INSTALLED_APPS -INSTALLED_APPS.append('django_slack') +INSTALLED_APPS.append('raven.contrib.django.raven_compat') # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.abspath(os.path.join( @@ -135,17 +132,57 @@ X_FRAME_OPTIONS = 'DENY' SECURE_CONTENT_TYPE_NOSNIFF = True SECURE_BROWSER_XSS_FILTER = True -# Slack configuration -SLACK_TOKEN = os.environ.get('DJANGO_SLACK_TOKEN') -SLACK_CHANNEL = '#django-errors' -SLACK_USERNAME = 'Concrexit' -SLACK_ICON_EMOJI = ':pingu:' -SLACK_FAIL_SILENTLY = True - -LOGGING = deepcopy(DEFAULT_LOGGING) -LOGGING['handlers']['slack-error'] = { - 'level': 'ERROR', - 'class': 'django_slack.log.SlackExceptionHandler', +LOGGING = { + 'version': 1, + 'disable_existing_loggers': True, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse', + }, + }, + 'root': { + 'level': 'WARNING', + 'handlers': ['sentry'], + }, + 'formatters': { + 'verbose': { + 'format': '%(levelname)s %(asctime)s %(module)s ' + '%(process)d %(thread)d %(message)s' + }, + }, + 'handlers': { + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'formatter': 'verbose' + }, + 'sentry': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'raven.contrib.django.raven_compat.' + 'handlers.SentryHandler', + }, + }, + 'loggers': { + 'django': { + 'handlers': ['console'], + 'level': 'INFO', + }, + 'raven': { + 'level': 'DEBUG', + 'handlers': ['console'], + 'propagate': False, + }, + 'sentry.errors': { + 'level': 'DEBUG', + 'handlers': ['console'], + 'propagate': False, + }, + }, +} + + +RAVEN_CONFIG = { + 'dsn': os.environ.get('SENTRY_DSN'), + 'release': os.environ.get('SOURCE_COMMIT'), } -LOGGING['loggers']['django']['handlers'].append('slack-error') -LOGGING['loggers']['django']['handlers'].remove('mail_admins')