https://github.com/nullstone-io/docker-django
Base docker image for Django
https://github.com/nullstone-io/docker-django
Last synced: 6 days ago
JSON representation
Base docker image for Django
- Host: GitHub
- URL: https://github.com/nullstone-io/docker-django
- Owner: nullstone-io
- License: mit
- Created: 2022-05-11T19:42:12.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-19T21:28:15.000Z (about 4 years ago)
- Last Synced: 2025-05-06T08:58:40.165Z (about 1 year ago)
- Language: Shell
- Size: 18.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nullstone/django
Django Base Image that is configured with different image tags for local and production.
This image is very opinionated; however, not restrictive.
## Quick Reference
- Maintained by
[Nullstone](https://nullstone.io)
- Where to get help
[Nullstone Slack](https://join.slack.com/t/nullstone-community/signup)
## Supported Tags and respective `Dockerfile` links
- [local](local.Dockerfile)
- [latest](Dockerfile)
## Images
This repository builds 2 variants of images: a local image and a production image.
All images are configured to log to stdout/stderr.
### Local
The local image variant is used to run python django in an isolated development environment on your local machine.
#### Dev Server
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.
#### Dependencies
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`.
#### Databases
Database environment variables are mapped to align with Nullstone conventions.
- If `POSTGRES_URL` is specified, set:
- `DB_ADAPTER=postgresql`
- `DATABASE_URL=$POSTGRES_URL`
- `SQLALCHEMY_DATABASE_URI=$POSTGRES_URL`
- If `MYSQL_URL` is specified, set
- `DB_ADAPTER=mysql`
- `DATABASE_URL=$MYSQL_URL`
- `SQLALCHEMY_DATABASE_URI=$MYSQL_URL`
### Production
The production image variant (any image tags that don't contain `local`) is used to run django in a production environment.
#### App Name
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 `.wsgi:application` where `` is the name of the directory that contains your `wsgi.py`.
#### Gunicorn
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 `:` to run
- `BINDING` - `:`
- `WEB_CONCURRENCY` - Sets number of workers; defaults to 2 * CPUs
- `PYTHON_MAX_THREADS` - Sets number of threads; defaults to 1
#### Databases
Database environment variables are mapped to align with Nullstone conventions.
- If `POSTGRES_URL` is specified, set:
- `DB_ADAPTER=postgresql`
- `DATABASE_URL=$POSTGRES_URL`
- `SQLALCHEMY_DATABASE_URI=$POSTGRES_URL`
- If `MYSQL_URL` is specified, set
- `DB_ADAPTER=mysql`
- `DATABASE_URL=$MYSQL_URL`
- `SQLALCHEMY_DATABASE_URI=$MYSQL_URL`