# Dockerfile for Django app

FROM python:3.7

# copy source and install dependencies
WORKDIR /bin/app
RUN mkdir -p /bin/app/django_backend
COPY src/python/apps/django_backend/start-server.sh /bin/app/
COPY src/python/apps/django_backend/.env.in /bin/app/
COPY src.python.apps.django_backend/gunicorn_run.pex /bin/app/django_backend
RUN chown -R www-data:www-data /bin/app/django_backend

# start server
EXPOSE 8000
STOPSIGNAL SIGTERM

RUN ["chmod", "+x", "/bin/app/start-server.sh"]
ENTRYPOINT ["/bin/app/start-server.sh"]

HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=6 CMD [ "curl http://localhost:8000/" ]