Skip to content

Instantly share code, notes, and snippets.

@dcwatson
Created July 11, 2018 20:39
Show Gist options
  • Save dcwatson/a55f1217553c28d1dc6248c26b26bc51 to your computer and use it in GitHub Desktop.
Save dcwatson/a55f1217553c28d1dc6248c26b26bc51 to your computer and use it in GitHub Desktop.
Django Dockerfile example
FROM python:3-slim
ENV LANG=C.UTF-8 \
PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE=project.settings.docker
COPY requirements.txt /app/
RUN pip install --no-cache-dir -Ur /app/requirements.txt
COPY . /app
RUN set -x && \
mkdir -p /data && \
python /app/manage.py collectstatic --noinput && \
useradd -g root -MN app && \
chown -R app:0 /app /data && \
chmod g+s /app /data
WORKDIR /app
USER app
VOLUME ["/data"]
EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "--access-logfile", "-", "project.wsgi"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment