Banno / getsentry-ldap-auth

A Sentry extension to add an LDAP server as an authention source.
Apache License 2.0
163 stars 54 forks source link

Installation fails with docker and debian jessie #14

Closed azmeuk closed 8 years ago

azmeuk commented 8 years ago

Hi. I tried to install the sentry ldap plugin on a sentry docker installation (by adding sentry-ldap-auth to requirements.txt). Docker version is 1.12.1.

When I try to build everything, it fails on the python-ldap pip installation, with this error code:

    Modules/errors.h:8:18: fatal error: lber.h: No such file or directory
     #include "lber.h"
                      ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

This is weird, because the package libldap2-dev is installed, the file lber.h is installed on my system. Also, if I try to install sentry-ldap-auth in a virtualenv in my host system, everything works well.

What do you think?

ChadKillingsworth commented 8 years ago

Here's what our docker file has:

FROM sentry:8.5

# Install dependencies for LDAP authentication
RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev

@barronhagerman Should we add this to the README?

azmeuk commented 8 years ago

Edit: Finally, it does not work with the following Dockerfile. I just forgot to re-add sentry-ldap-auth to the requirements.txt file.

FROM sentry:8.8-onbuild

# Install dependencies for LDAP authentication
RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev

Edit 2: Well, it works with FROM sentry:8.8 instead of FROM sentry:8.8-onbuild. Thanks!

ChadKillingsworth commented 8 years ago

Actually, @barronhagerman do you think we can switch ldap packages? See the instructions on https://bitbucket.org/psagers/django-auth-ldap/pull-requests/20/switched-to-python3-ldap/diff

I have no idea if it will actually work, but it would be worth testing.

azmeuk commented 8 years ago

Ok. Finally I think it does not work. I am sorry, actually I am a bit new to docker.

I understand that sentry:onbuild and sentry are two different docker images. sentry:onbuild installs pip dependencies but not the apt ones. And sentry installs the apt dependencies, but not the pip ones. How can I solve this?

Edit

Ok I got it this time. I copied the original onbuild Dockerfile and inserted the apt command.

FROM sentry:8.8

WORKDIR /usr/src/sentry

# Add WORKDIR to PYTHONPATH so local python files don't need to be installed
ENV PYTHONPATH /usr/src/sentry
ONBUILD COPY . /usr/src/sentry

# Install dependencies for LDAP authentication
RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev

# Hook for installing additional plugins
ONBUILD RUN if [ -s requirements.txt ]; then pip install -r requirements.txt; fi

# Hook for installing a local app as an addon
ONBUILD RUN if [ -s setup.py ]; then pip install -e .; fi

# Hook for staging in custom configs
ONBUILD RUN if [ -s sentry.conf.py ]; then cp sentry.conf.py $SENTRY_CONF/; fi \
&& if [ -s config.yml ]; then cp config.yml $SENTRY_CONF/; fi

Edit 2

I cannot find the AUTH_LDAP configuration fields in the sentry 'environment' page. Something must have gone wrong.

barronhagerman commented 8 years ago

I have not used ONBUILD, but I think that is what you would use if you were creating an image that would be the base for other images. Try removing ONBUILD from all of those lines, rebuild your image, and try again.

Also, before you do pip install, you'll probably need to ADD requirements.txt

barronhagerman commented 8 years ago

Also, @azmeuk, you'll need to create a custom configuration file. Something like this:

from sentry_docker_conf import *

AUTH_LDAP_SERVER_URI = 'ldap://my.ldapserver.com'

AUTH_LDAP_USER_SEARCH = LDAPSearch(
    'dc=domain,dc=com',
    ldap.SCOPE_SUBTREE,
    '(mail=%(user)s)',
)

...

Then, set ENV SENTRY_CONF_FILE custom_settings.py in your Dockerfile

azmeuk commented 8 years ago

@barronhagerman Thanks, I will try that. Do you a have a working Dockerfile sample?

barronhagerman commented 8 years ago
FROM sentry:8.8

# Install dependencies for LDAP authentication
RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev

# Install dependencies for symsynd (for dSYM support)
RUN apt-get install -y clang g++

ADD requirements.txt /conf/
RUN pip install -r /conf/requirements.txt

ADD dsym_s3_import.sh /conf/

ENV SENTRY_CONF /conf
ADD config.yml $SENTRY_CONF/
ADD sentry.conf.py $SENTRY_CONF/
ENV PYTHONPATH /conf
barronhagerman commented 8 years ago

I'm closing this issue because I don't think it is a problem with the sentry-ldap-auth package. If you continue to have troubles, I'll try to help.