Django Base Image that is configured with different image tags for local and production. This image is very opinionated; however, not restrictive.
Dockerfile linksThis repository builds 2 variants of images: a local image and a production image.
All images are configured to log to stdout/stderr.
The local image variant is used to run python django in an isolated development environment on your local machine.
The local variant is configured to run the built-in server using the conventional ./manage.py runserver.
This image does not contain a manage.py; this requires a valid manage.py located in your repository to work properly.
The server listens on port 9000 by default to align with Nullstone conventions to quickly attach an nginx sidecar (example coming soon)
To change this port, use PORT environment variable.
This image detects requirements.txt or poetry.lock files and installs dependencies on boot.
To update dependencies in a container using this image, restart the docker container.
On boot, the image will run either pip install -r requirements.txt or poetry install.
Database environment variables are mapped to align with Nullstone conventions.
POSTGRES_URL is specified, set:
DB_ADAPTER=postgresqlDATABASE_URL=$POSTGRES_URLSQLALCHEMY_DATABASE_URI=$POSTGRES_URLMYSQL_URL is specified, set
DB_ADAPTER=mysqlDATABASE_URL=$MYSQL_URLSQLALCHEMY_DATABASE_URI=$MYSQL_URLThe production image variant (any image tags that don't contain local) is used to run django in a production environment.
When creating a Dockerfile for your app, you will need to set WSGI_APP based on your application name.
The format for typical Django projects is <project-directory>.wsgi:application where <project-directory> is the name of the directory that contains your wsgi.py.
The production variant is configured to run a production server using gunicorn.
There is a standard gunicorn.conf.py packaged with this image that accepts the following env vars:
WSGI_APP - accepts <module>:<app> to runBINDING - <addr>:<port>WEB_CONCURRENCY - Sets number of workers; defaults to 2 * CPUsPYTHON_MAX_THREADS - Sets number of threads; defaults to 1Database environment variables are mapped to align with Nullstone conventions.
POSTGRES_URL is specified, set:
DB_ADAPTER=postgresqlDATABASE_URL=$POSTGRES_URLSQLALCHEMY_DATABASE_URI=$POSTGRES_URLMYSQL_URL is specified, set
DB_ADAPTER=mysqlDATABASE_URL=$MYSQL_URLSQLALCHEMY_DATABASE_URI=$MYSQL_URLContent type
Image
Digest
Size
23 MB
Last updated
over 4 years ago
docker pull nullstone/django