1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#syntax=docker/dockerfile:1.4
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}-alpine as python
FROM python AS python-build-stage
ARG REQUIREMENTS_FILE=local.txt
RUN <<EOF
apk update
# CFFI dependencies
apk add libffi-dev py-cffi
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
apk add postgresql-client
EOF
# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r /requirements/${REQUIREMENTS_FILE}
FROM python as python-run-stage
ENV PYTHONUNBUFFERED 1
RUN <<EOF
apk update
# Translations dependencies
apk add gettext
# https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
apk add postgresql-client
EOF
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
RUN <<EOF
pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/*
rm -rf /wheels/
EOF
COPY ./compose/local/django/entrypoint /entrypoint
RUN sed -i 's/\r//' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/local/django/start /start
RUN sed -i 's/\r//' /start
RUN chmod +x /start
COPY ./compose/local/django/start_asgi /start_asgi
RUN sed -i 's/\r//' /start_asgi
RUN chmod +x /start_asgi
COPY ./compose/local/django/start_wsgi /start_wsgi
RUN sed -i 's/\r//' /start_wsgi
RUN chmod +x /start_wsgi
COPY ./compose/local/django/celery/worker/start /start-celeryworker
RUN sed -i 's/\r//' /start-celeryworker
RUN chmod +x /start-celeryworker
COPY ./compose/local/django/celery/beat/start /start-celerybeat
RUN sed -i 's/\r//' /start-celerybeat
RUN chmod +x /start-celerybeat
COPY ./compose/local/django/celery/flower/start /start-flower
RUN sed -i 's/\r//' /start-flower
RUN chmod +x /start-flower
WORKDIR /app
RUN addgroup --system django \
&& adduser --system --ingroup django django
RUN chown django:django /app
ENTRYPOINT ["/entrypoint"]
|