From 8ad8cbf9952892a8264cffb75d6b8a7c5408852e Mon Sep 17 00:00:00 2001 From: Matheus Fernandes Date: Tue, 21 Nov 2017 15:24:00 -0200 Subject: [PATCH] Add tos colab plugin and logging configuration Signed-off-by: Matheus Fernandes --- Dockerfile | 11 +++++--- misc/etc/colab/plugins.d/tos.py | 22 ++++++++++++++++ misc/etc/colab/settings.d/03-logging.py | 34 +++++++++++++++++++++++++ start-colab.sh | 3 ++- 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 misc/etc/colab/plugins.d/tos.py create mode 100644 misc/etc/colab/settings.d/03-logging.py diff --git a/Dockerfile b/Dockerfile index b6df961c..09d6c8e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ENV BUILD_PACKAGES python-dev python3 python3-dev linux-headers \ RUN apk add --update --no-cache $BUILD_PACKAGES RUN mkdir -p /etc/colab /etc/colab/settings.d /etc/colab/plugins.d \ /etc/colab/widgets.d /var/labhacker/colab/public/media \ - /etc/cron.d/ + /etc/cron.d/ /var/log/colab/ ADD . /var/labhacker/colab WORKDIR /var/labhacker/colab @@ -15,16 +15,21 @@ WORKDIR /var/labhacker/colab RUN pip install . psycopg2 gunicorn elasticsearch python-memcached easy_thumbnails && \ rm -r /root/.cache -RUN pip install colab-edemocracia colab-audiencias colab-discourse colab-wikilegis +RUN pip install colab-edemocracia colab-audiencias colab-discourse \ + colab-wikilegis colab-mkdocs-tos COPY ./misc/etc/colab/settings.py ./misc/etc/colab/gunicorn.py /etc/colab/ COPY ./misc/etc/colab/settings.d/01-database.py \ ./misc/etc/colab/settings.d/02-memcached.py \ + ./misc/etc/colab/settings.d/03-logging.py \ /etc/colab/settings.d/ -COPY ./misc/etc/colab/plugins.d/edemocracia.py /etc/colab/plugins.d/ +COPY ./misc/etc/colab/plugins.d/edemocracia.py \ + ./misc/etc/colab/plugins.d/tos.py \ + /etc/colab/plugins.d/ RUN npm install -g bower && \ colab-admin bower_install --allow-root && \ colab-admin collectstatic --noinput && \ + colab-admin build_mkdocs && \ colab-admin compilemessages diff --git a/misc/etc/colab/plugins.d/tos.py b/misc/etc/colab/plugins.d/tos.py new file mode 100644 index 00000000..88f61e73 --- /dev/null +++ b/misc/etc/colab/plugins.d/tos.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +name = 'colab_mkdocs_tos' +verbose_name = 'Colab Mkdocs Plugin Plugin' + +upstream = '' + +docs_title = "Sobre" + +pages = [ + ('Página Inicial', 'index.md'), + ('Wikilegis', 'wikilegis.md'), + ('Audiências Interativas', 'audiencias.md'), + ('Expressão', 'expressao.md'), + ('Termos de Serviço', 'tos.md'), +] + + +urls = { + 'include': 'colab_mkdocs_tos.urls', + 'prefix': '^sobre/', +} \ No newline at end of file diff --git a/misc/etc/colab/settings.d/03-logging.py b/misc/etc/colab/settings.d/03-logging.py new file mode 100644 index 00000000..7275be36 --- /dev/null +++ b/misc/etc/colab/settings.d/03-logging.py @@ -0,0 +1,34 @@ +LOGGING = { + 'version': 1, + 'disable_existing_loggers': True, + 'formatters': { + 'verbose': { + 'format': '%(asctime)s (%(name)s) %(levelname)s: %(message)s' + } + }, + 'handlers': { + 'file': { + 'level': 'DEBUG', + 'interval': 24, + 'backupCount': 7, + 'encoding': 'UTF-8', + 'formatter': 'verbose', + 'class': 'logging.handlers.TimedRotatingFileHandler', + 'filename': '/var/log/colab/colab.log', + } + }, + 'loggers': { + 'revproxy': { + 'handlers': ['file'], + 'level': 'ERROR', + }, + 'django': { + 'handlers': ['file'], + 'level': 'ERROR', + }, + 'colab': { + 'handlers': ['file'], + 'level': 'ERROR', + }, + }, +} diff --git a/start-colab.sh b/start-colab.sh index 5c786bae..18cf3d7f 100755 --- a/start-colab.sh +++ b/start-colab.sh @@ -2,7 +2,7 @@ PLUGINS_SETTINGS="/etc/colab/plugins.d/" if [ "$(ls -A $PLUGINS_SETTINGS)" ]; then - find $PLUGINS_SETTINGS ! -name 'edemocracia.py' -type f -exec rm -f {} + + find $PLUGINS_SETTINGS ! -name 'edemocracia.py' ! -name 'tos.py' -type f -exec rm -f {} + fi PLUGINS_WIDGETS="/etc/colab/widgets.d/" @@ -44,6 +44,7 @@ PGPASSWORD=$DATABASE_PASSWORD psql -U $DATABASE_USER -w -h $DATABASE_HOST -c "CR colab-admin migrate colab-admin initdb +colab-admin bower_install --allow-root colab-admin compress --force colab-admin collectstatic --noinput