FROM registry.yandex.net/mail/mail-xenial-common:latest

RUN wget --quiet -O - http://mirror.yandex.ru/mirrors/postgresql/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://mirror.yandex.ru/mirrors/postgresql/ xenial-pgdg main" >> /etc/apt/sources.list.d/pgdg.list

RUN apt-get update && apt-get install -y nginx=1.14.2-1.yandex.15 lua-cjson
RUN ln -sf /usr/lib/x86_64-linux-gnu/lua/ /usr/local/lib/lua
RUN apt-get autoremove -y && apt-get clean

COPY etc /etc
COPY entrypoint.sh /entrypoint.sh
COPY bin /opt/bin

RUN mv /opt/bin/bin /opt/bin/beagle
RUN chmod u+x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]