# TODO https://github.com/Kazanz/docker-nginx-uwsgi-django/blob/master/Dockerfile
#FROM ubuntu:16.04


#RUN apt-get update 
#Install python dependencies
#RUN apt-get install -y python3-dev python3 python3-pip python3
# install nginx
#RUN apt-get install -y nginx
# install install packet dependencies
#RUN apt-get install -y mysql-client libmysqlclient-dev libssl-dev

#RUN mkdir -p /code
#RUN mkdir -p /run
#WORKDIR /code
#ADD requirements.txt /code/
#ADD scripts/production/nginx.conf /etc/nginx/sites-enabled/default

#RUN pip3 install -r requirements.txt
#ADD . /code/
#RUN python3 manage.py collectstatic --no-input

#EXPOSE 80

#ENTRYPOINT ["/usr/bin/uwsgi", "/code/scripts/production/uwsgi.ini"]
#ENTRYPOINT ["/bin/bash"]

FROM python:3.5-alpine

RUN apk add --update \
    nginx \
    supervisor \ 
    python-dev \
    build-base \
    linux-headers \
    pcre-dev \
    py-pip \ 
    vim \
    mysql-client \
    mysql-dev \
    openssl-dev \
    libffi-dev \
    jpeg-dev \
    zlib-dev\
&& rm -rf /var/cache/apk/* \
&& chown -R nginx:www-data /var/lib/nginx

RUN mkdir -p /code
RUN mkdir -p /run
RUN mkdir -p /run/nginx
RUN chmod -R 777 /run

WORKDIR /code
ADD . /code/
ADD requirements.txt /code/

RUN pip install -r requirements.txt
RUN python manage.py collectstatic --no-input


RUN rm -f /etc/nginx/nginx.conf
ADD scripts/production/nginx.conf /etc/nginx/nginx.conf
RUN mkdir /etc/nginx/sites-enabled
ADD scripts/production/nginx-app.conf /etc/nginx/sites-enabled/default

RUN rm /etc/supervisord.conf
ADD scripts/production/supervisord.conf /etc/supervisord.conf
CMD ["supervisord", "-n"]
