From c604a90c7f4662e48aac44afec9151b886e47914 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Apr 05 2018 20:44:31 +0000 Subject: Fix logging commits in docker-container dev env This fixes up several problems with logging commits in the docker dev env. We did not have an equivalent of pagure_logcom running at all, first of all. There were also several issues preventing the default commit hook from running properly. The file is not executable, which meant the hook wouldn't be run at all (@cverna noticed this). PYTHONPATH not being set as an env var in the web container meant the hook couldn't find the pagure module. And PAGURE_CONFIG not being set as an env var in the web container meant the hook couldn't find the correct pagure config file for the dev environment. With all these things fixed, if you clone a repo from the dev instance *inside* the web container (it currently only works that way) and then push a commit to it (using an email address associated with a user that exists), the hook runs, and the commit is properly logged to the database, and shows up in the user's activity log. Signed-off-by: Adam Williamson --- diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 0f38c1b..b68b52c 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -16,6 +16,10 @@ services: - ../lcl/repos:/repos - ../lcl/attachments:/attachments - ..:/code:z + environment: + - GL_USER=root + - PYTHONPATH=/code + - PAGURE_CONFIG=/code/dev/openshift.cfg worker: build: context: ./docker @@ -31,6 +35,21 @@ services: environment: - PYTHONPATH=. - PAGURE_CONFIG=/code/dev/openshift.cfg + logcom: + build: + context: ./docker + dockerfile: logcom + depends_on: + - redis + - postgresql + image: pagure-logcom:latest + volumes: + - ../lcl/repos:/repos + - ../lcl/attachments:/attachments:ro + - ..:/code:z + environment: + - PYTHONPATH=. + - PAGURE_CONFIG=/code/dev/openshift.cfg ev: build: context: ./docker diff --git a/dev/docker/logcom b/dev/docker/logcom new file mode 100644 index 0000000..d56c488 --- /dev/null +++ b/dev/docker/logcom @@ -0,0 +1,26 @@ +FROM registry.fedoraproject.org/fedora:27 +MAINTAINER Patrick Uiterwijk + +VOLUME ["/repos"] +RUN mkdir /code + +RUN dnf install -y python2-devel python-setuptools python-nose python2-bcrypt python-alembic \ + python-arrow python-binaryornot python-bleach python-blinker \ + python-chardet python-cryptography python-docutils python-flask \ + python-flask-wtf python-flask-multistatic python-markdown python-psutil \ + python-pygit2 python-pygments python-fedora python-openid python-openid-cla \ + python-openid-teams python-straight-plugin python-wtforms python-munch \ + python-enum34 python-redis python-sqlalchemy systemd gitolite3 python-filelock \ + python-fedora-flask python2-pillow python2-psycopg2 + +RUN dnf install -y python2-celery + +WORKDIR /code +ENTRYPOINT ["/usr/bin/celery", "-A", "pagure.lib.tasks_services", "worker", "--loglevel", "info", "-Q", "pagure_logcom"] + +# Code injection is last to make optimal use of caches +VOLUME ["/code"] +# Openshift: COPY / /code +VOLUME ["/attachments"] +# Ideally this would run as non-root, but that needs the /repos owned correctly +ENV C_FORCE_ROOT true diff --git a/pagure/hooks/files/default_hook.py b/pagure/hooks/files/default_hook.py old mode 100644 new mode 100755 index 00e13fd..00e13fd --- a/pagure/hooks/files/default_hook.py +++ b/pagure/hooks/files/default_hook.py