Django container, based on ubuntu:14.0.4.2, with Gunicorn as the entrypoint.
Gunicorn is the entrypoint, so pass in any arguments that you'll need.
--workers=4
DJANGO_PROJECT is a required environment variable that must be set, as this is used to start Gunicorn with your Django project. (the project should be mounted at /opt/PROJECT_NAME)
(% gunicorn $DJANGO_PROJECT.wsgi:application...)
eg.
% docker run \
-e DJANGO_PROJECT=some_project \
--volume `pwd`:/opt/some_project \
minty/django --workers=4
##Dockerfile (1.8 tag)
# Django
#
# VERSION 1
#
# docker build -t minty/django .
#
FROM ubuntu:14.04.2
MAINTAINER Justin Wilson <[email protected]>
RUN apt-get update
RUN apt-get install -y \
openssl \
libssl-dev \
python \
python-pip
# Upgrade pip (`python-pip` is old and the requests library breaks it)
RUN pip install --upgrade pip
RUN ln -s /usr/local/bin/pip /usr/bin/pip
RUN pip install Django==1.8
RUN pip install gunicorn==19.3.0
# Add web user
RUN groupadd -r www && useradd -r -g www www
# Gunicorn startup script
COPY gunicorn_start.sh /usr/local/bin/
EXPOSE 8000
USER www
ENTRYPOINT ["gunicorn_start.sh"]
CMD ["--help"]
##Startup Script
#!/bin/bash
if [ -z "$DJANGO_PROJECT" ]; then
echo "Missing 'DJANGO_PROJECT' environment variable."
exit 1
fi
has_bind=false
gunicorn_args=''
while test $# -gt 0; do
case "$1" in
--bind|-b)
has_bind=true
gunicorn_args="$gunicorn_args$1 $2 "
shift
shift
;;
*)
gunicorn_args="$gunicorn_args$1 "
shift
;;
esac
done
if [ $has_bind = false ]; then
gunicorn_args="$gunicorn_args--bind 0.0.0.0:8000"
fi
cd /opt/$DJANGO_PROJECT
if [ $? -ne 0 ]; then
exit 1
fi
gunicorn $DJANGO_PROJECT.wsgi:application$@ $gunicorn_args
Content type
Image
Digest
sha256:b18c51edc…
Size
-
Last updated
over 11 years ago
docker pull minty/django