Skip to content

Instantly share code, notes, and snippets.

@Andrej1A
Created July 13, 2020 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrej1A/cc97d1f681b0df024bf2a067a8a5c7b6 to your computer and use it in GitHub Desktop.
Save Andrej1A/cc97d1f681b0df024bf2a067a8a5c7b6 to your computer and use it in GitHub Desktop.
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