FROM registry.yandex.net/ubuntu:xenial

RUN apt-get update -y && \
    apt-get install -y -q0 --no-install-recommends && \
    apt-get install -y supervisor libperl-dev nginx logrotate yandex-push-client

COPY score_api_server /score_api_server
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY push_client.yaml /score_api_server/push_client.yaml
COPY logrotate.conf /score_api_server/logrotate.conf

RUN chmod a-w /score_api_server/logrotate.conf && \
    echo "* * * * * /usr/sbin/logrotate /score_api_server/logrotate.conf -f" | crontab

# Fiq QLoud error with Cron
# pam_loginuid(cron:session): Error writing /proc/self/loginuid: Operation not permitted
RUN sed -i -r 's/^.*pam_(loginuid|limits).so/#\0/g' /etc/pam.d/cron

EXPOSE 80

# ["supervisord", "-n"]
CMD /usr/bin/supervisord
