https://github.com/logicify/docker-django
Django hosted with gunicorn behind nginx
https://github.com/logicify/docker-django
Last synced: 3 months ago
JSON representation
Django hosted with gunicorn behind nginx
- Host: GitHub
- URL: https://github.com/logicify/docker-django
- Owner: Logicify
- License: mit
- Created: 2016-05-21T19:43:19.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-03T09:49:17.000Z (over 5 years ago)
- Last Synced: 2024-04-15T03:17:54.305Z (about 1 year ago)
- Language: Python
- Size: 14.6 KB
- Stars: 2
- Watchers: 7
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Base image for django deployments
[](https://microbadger.com/images/logicify/django "Get your own image badge on microbadger.com")
This image is useful if you want to create **production setup** for your django application.
Essentially it runs 2 processes:* [gunicorn](http://gunicorn.org/) which actually hosts your django aplication
* [Nginx](https://nginx.org/en/) which serves static files and proxies the rest of requests to gunicorn
## Requirements1. You should put you django application code into the following folder of the image: `/srv/application`
1. Static files should be located under `/srv/static`
1. You need to point your application to put media into `/srv/media`.
1. It is required to pass env variable `APP_MODULE` which contains the name of the module to be used as wsgi entry point.
E.g. `your_app.wsgi`Ensure you updated your django settings accordingly (especially `MEDIA_ROOT` and `STATIC_ROOT`).
## ExamplesHere is an example of the Dockerfile which creates an image from the source code (it might be run on CI server
as a part of build process):```
FROM logicify/django:1.1COPY build/code /srv/application
COPY build/static /srv/staticRUN source /srv/virtenv/bin/activate && \
LANG=en_US.utf8 pip install -r requirements.txtENV APP_MODULE "our_app.wsgi"
ENV APP_PROCESS_NAME "our-app-name"```
So basically what it does is copying files from the build folder into valid locations, setting up all dependencies an
required variables. As result you have ready to deploy image.## Supported Variables
* **PROXY_TIMEOUT** - timeout in seconds for nginx proxy (default `90`)
* **STATIC_URL** - url path for static files hosting (default `/static`)
* **STATIC_PATH** - location on the file system where nginx should find static files (`/srv/static`)
* **MEDIA_PATH** - location on the file system where nginx should find media files (`/srv/media`)