############################################################
# Dockerfile to build SecNotify
############################################################

FROM registry.yandex.net/ubuntu:focal
MAINTAINER Yaroslav Buchnev "ybuchnev@yandex-team.ru"

ENV TZ=Europe/Moscow
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN set -xe && \
    apt-get -y update && \
    apt-get install -y --no-install-recommends apt-utils && \
    apt-get -y --force-yes install \
                           git \
                           net-tools \
                           telnet \
                           iputils-ping \
                           python3 \
                           supervisor \
                           nano \
                           host \
                           tmux \
                           checkinstall \
                           libreadline-gplv2-dev \
                           libncursesw5-dev \
                           libssl-dev \
                           libsqlite3-dev \
                           tk-dev \
                           libgdbm-dev \
                           libc6-dev \
                           libbz2-dev \
                           zlib1g-dev \
                           openssl \
                           libffi-dev \
                           python3-dev \
                           python3-setuptools \
                           python3-pip

# Copy the internal cert file inside the container
ADD ca-certificates.crt /etc/ssl/certs/

# Copy the requirements file inside the container
ADD ./requirements.txt /tmp/requirements.txt

# Get pip to download and install requirements:
RUN pip3 install -r /tmp/requirements.txt

# Copy the application folder inside the container
ADD ./src/ /back/

# Set the default directory where shell will execute
WORKDIR /back

# Create log file
RUN mkdir /var/log/secnotify && \
    touch /var/log/secnotify/secnotify.log

# Set the default command to execute, when creating a new container
CMD ./run_gunicorn.sh