FROM python:3.6

ENV PATH="/usr/local/bin:$PATH"

COPY . /srv/apps/sun/

WORKDIR /root/.ssh/

ADD ssh/id_rsa .

ADD ./sources.list /etc/apt/sources.list

WORKDIR /srv/apps/sun/

RUN chmod -R 600 /root/.ssh/id_rsa \
    && echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config \
    && mkdir -p /data/log/sun/app

RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32 \
    && apt-get -y update && apt-get -y install mysql-client libmysqlclient-dev \
    && apt-get clean \
    && apt-get autoclean \
    && rm -rf /var/lib/apt/lists/*

RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

ENTRYPOINT bash -c 'source ~/.bashrc && gunicorn sun.wsgi:application -w 4 -b 0.0.0.0:8090 -k gevent'
