FROM debian:stretch
#FROM python:3

EXPOSE 8000

WORKDIR /

RUN apt-get update

RUN apt-get install -y python-virtualenv python-pip

RUN virtualenv -p python3 venv

# ponechano kvuli vyuziti cache 
#RUN bash -c 'source /venv/bin/activate; pip install -r pip-requirements.txt'
RUN bash -c 'source /venv/bin/activate; pip install Django==2.0.3 psycopg2==2.7.4 django-statici18n==1.7.0 django-auth-oidc==0.4.5 pyjwkest==1.4.0 bleach==2.1.4 django-anymail==3.0 html2text==2018.1.9'

ADD . /nalodeni/

#RUN bash -c 'touch /nalodeni/main/settings_local.py'   # this file needs to exist
#RUN adduser --disabled-login --quiet --gecos nalodeni nalodeni
#RUN chown -R nalodeni:nalodeni /nalodeni/
#RUN chmod u+x /nalodeni/docker-entrypoint.sh
RUN bash -c 'adduser --disabled-login --quiet --gecos nalodeni nalodeni &&  \
             chmod -R o+r /nalodeni/ && \
             chown -R nalodeni:nalodeni /nalodeni/static_files && \
             chmod o+x /nalodeni/docker-entrypoint.sh && \
             touch /nalodeni/main/settings_local.py '

USER nalodeni

ENTRYPOINT /nalodeni/docker-entrypoint.sh
