Dockerfile 1.01 KB
Newer Older
1
FROM python:3.7 as django
2
LABEL mantainer "Hacklab <contato@hacklab.com.br>"
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
ENV PYTHONUNBUFFERED 1


# Requirements have to be pulled and installed here, otherwise caching won't work
COPY ./requirements /requirements
RUN pip install --no-cache-dir -r /requirements/production.txt \
    && rm -rf /requirements

COPY ./compose/production/django/gunicorn.sh /gunicorn.sh
RUN sed -i 's/\r//' /gunicorn.sh
RUN chmod +x /gunicorn.sh

COPY ./compose/production/django/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh
RUN chmod +x /entrypoint.sh

COPY . /app

# env.example must be used during build to provide a valid environment
RUN export $(cat /app/env.example | grep -v ^# | xargs) && \
23 24
    python /app/manage.py collectstatic --noinput && \
    python /app/manage.py compress
25 26 27 28 29 30 31

WORKDIR /app

ENTRYPOINT ["/entrypoint.sh"]
CMD ["/gunicorn.sh"]


32
FROM nginx:1.16 as nginx
33 34 35

COPY ./compose/production/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=django /app/staticfiles/static/ /usr/share/nginx/html/static/