FROM python:3
#TODO as an educational env, we sould use debian or centos. more like debian? A dockerfile each?

RUN apt update && apt install -y gcc nginx openssh-server
RUN pip3 install uwsgi

WORKDIR /app

RUN addgroup eleve

# Python app
COPY python_app/ ./python_app

ENV UID=33
ENV MOUNT=/
ENV TZ=Europe/Paris

RUN mkdir /tmp/uwsgi
CMD ["uwsgi", "-s", "/tmp/uwsgi/uwsgi.sock", "--chown-socket", "${UID}", "--manage-script-name", "--mount", "${MOUNT}=python_app.main:application", "--http-timeout", "10", "--master", "--hook-master-start", "'unix_signal:15 gracefully_kill_them_all'", "--need-app", "--die-on-term", "--show-config", "--log-master", "--strict", "--vacuum", "--single-interpreter"]
#CMD ["sh", "-c", "echo lol"]

# SSH server
RUN mkdir /run/sshd

# Nginx server
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./nginx/favicon.ico ./

# Entrypoint
COPY ./entrypoint.sh ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]