hub.docker.com/r/telling/django
Based on the official python images.
Simplifying developing django applications by providing a few shorthands for manage.py:
runserver host:port
migrate, collectstatic and lastly runserver.nomigrate host:port
collectstatic followed by runserver.makemigrations and loadtestdata
makemigrations or loadtestdata.If environment variables DJANGO_SUPERUSER_* are set, runserver and nomigrate will attempt to create the superuser. Likewise, if the DJANGO_DB_* variables are set, it will wait for the database upon starting the container, the image uses dockerize to wait for the database. Other then that it behaves like the official python images, with the environment variable PYTHONUNBUFFERED set, django and a few extra packages installed.
DJANGO_DB_HOSTDJANGO_DB_PORTDJANGO_SUPERUSER_NAMEDJANGO_SUPERUSER_MAILDJANGO_SUPERUSER_PASSPYTHONUNBUFFEREDDOCKERIZE_VERSIONDJANGO_VERSIONTo start a new project and create a new app:
docker run --rm --log-driver none -v $(pwd):/code telling/django:1.9.7-py3 django-admin startproject mysite
docker run --rm --log-driver none -v $(pwd)/mysite:/code telling/django:1.9.7-py3 python manage.py startapp polls
I've recently used this to get a local development environment for the bornhack website.
I created a very simple dockerfile, which copies the requirements files and installs said requirements, Dockerfile:
FROM telling/django:1.9.7-py2
COPY requirements/base.txt base.txt
COPY requirements/development.txt development.txt
RUN pip install -r development.txt
CMD ["runserver", "0.0.0.0:8000"]
Then using the dockerfile in docker-compose.yml:
version: "2"
services:
postgres:
image: postgres:9.5
container_name: bornhack-postgres
environment:
- POSTGRES_PASSWORD=bornhack
- POSTGRES_USER=bornhack
- POSTGRES_DB=bornhack_dev
django:
build: .
volumes:
- .:/code
container_name: bornhack-django
ports:
- "8000:8000"
environment:
- DJANGO_DB_HOST=postgres
- DJANGO_DB_PORT=5432
- DJANGO_SUPERUSER_NAME=bornhack
- DJANGO_SUPERUSER_PASS=bornhack
- [email protected]
- DJANGO_SETTINGS_MODULE=bornhack.settings.development
Change the settings file bornhack/settings/development.py and replace 'HOST': 'localhost', with 'HOST': 'postgres',. Now copy the environment file: cp bornhack/settings/env.dist bornhack/settings/.env
We end with a tree structure like:
.
├── Dockerfile
├── Makefile
├── README.md
├── bornhack
├── camps
├── docker-compose.yml
├── graphics
├── manage.py
├── news
├── profiles
├── requirements
├── shop
├── utils
├── vendor
└── villages
Then we can start hacking on the bornhack website by simply doing:
Go to localhost:8000 and see the bornhack website in all its beauty.
Content type
Image
Digest
Size
271.5 MB
Last updated
almost 10 years ago
docker pull telling/django