# Use an official Python runtime as a parent image
FROM registry.yandex.net/ubuntu:trusty
MAINTAINER Anton Grigoryev <griganton@yandex-team.ru>

# environment variables
ENV WORKDIR /sentry
ENV SENTRY_CONF=/etc/sentry

# make celery work under root
ENV C_FORCE_ROOT=1

# Set the working directory to
WORKDIR $WORKDIR

# debian dependencies
RUN apt-get update && apt-get install -y --force-yes \
    cdbs \
    python-central \
    python-dev \
    gcc \
    libffi-dev \
    libjpeg-dev \
    libxml2-dev \
    libxslt-dev \
    libyaml-dev \
    libpq-dev \
    redis-tools \
    haproxy

# NOTE: there are issues with pip upgrade and this workaround have been
# proposed here: https://github.com/moby/moby/issues/12327#issuecomment-171496303
RUN apt-get install python-pip -y --force-yes && pip install --upgrade pip

# install python packages
RUN pip install setuptools
RUN pip install supervisor redis==2.10.5 sentry==9.0.0

# Copy configs
ADD deploy/haproxy /etc/haproxy
ADD deploy/sentry $SENTRY_CONF
ADD deploy/supervisord.conf /etc/supervisord.conf
ADD deploy/sentry_cleanup.sh /sentry/sentry_cleanup.sh
ADD deploy/sentry_cleanup.cron /etc/cron.d/sentry_cleanup

ADD scripts /scripts

# start supervisord
CMD ["/usr/local/bin/supervisord"]
