Skip to content

Instantly share code, notes, and snippets.

@Andrej1A
Created Jul 13, 2020
Embed
What would you like to do?
Dockerfile for Django-Application
FROM python:3.6-stretch
ARG DJANGO_ENV=dev
ENV PYTHONUNBUFFERED 1
# Requirements have to be pulled and installed here, otherwise caching won't work
COPY ./requirements/base.txt /base.txt
COPY ./requirements/cloud_production.txt /cloud_production.txt
COPY ./requirements/${DJANGO_ENV}.txt /requirements_${DJANGO_ENV}.txt
RUN apt-get update \
&& apt-get install -y apt-utils libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev python-setuptools python-dev build-essential python3-all-dev python3-dev gdal-bin libgdal-dev python3-gdal git gettext \
&& pip install -r /requirements_${DJANGO_ENV}.txt \
&& pip install psycopg2-binary \
&& groupadd -r django \
&& useradd -m -r -g django django
COPY ./entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY . /app
RUN chown -R django /app
COPY ./start_wsgi_server.sh /start_wsgi_server.sh
RUN sed -i 's/\r//' /start_wsgi_server.sh \
&& chmod +x /start_wsgi_server.sh \
&& chown django /start_wsgi_server.sh
WORKDIR /app
RUN mkdir /data \
&& chown django.django /data
RUN mkdir /data/static \
&& chown django.django /data/static
RUN mkdir /data/media \
&& chown django.django /data/media
ENTRYPOINT ["/entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment