Skip to content

Commit b6b5ecb

Browse files
author
Dmitry Berezovsky
committed
Added readme
1 parent dc49023 commit b6b5ecb

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Base image for django deployments
2+
3+
[![](https://images.microbadger.com/badges/image/logicify/django.svg)](https://microbadger.com/images/logicify/django "Get your own image badge on microbadger.com")
4+
5+
This image is useful if you want to create **production setup** for your django application.
6+
Essentially it runs 2 processes:
7+
8+
* [gunicorn](http://gunicorn.org/) which actually hosts your django aplication
9+
* [Nginx](https://nginx.org/en/) which serves static files and proxies the rest of requests to gunicorn
10+
11+
## Requirements
12+
13+
1. You should put you django application code into the following folder of the image: `/srv/application`
14+
1. Static files should be located under `/srv/static`
15+
1. You need to point your application to put media into `/srv/media`.
16+
1. It is required to pass env variable `APP_MODULE` which contains the name of the module to be used as wsgi entry point.
17+
E.g. `your_app.wsgi`
18+
19+
Ensure you updated your django settings accordingly (especially `MEDIA_ROOT` and `STATIC_ROOT`).
20+
21+
## Examples
22+
23+
Here is an example of the Dockerfile which creates an image from the source code (it might be run on CI server
24+
as a part of build process):
25+
26+
```
27+
FROM logicify/django:1.1
28+
29+
COPY build/code /srv/application
30+
COPY build/static /srv/static
31+
32+
RUN source /srv/virtenv/bin/activate && \
33+
LANG=en_US.utf8 pip install -r requirements.txt
34+
35+
ENV APP_MODULE "our_app.wsgi"
36+
ENV APP_PROCESS_NAME "our-app-name"
37+
38+
```
39+
40+
So basically what it does is copying files from the build folder into valid locations, setting up all dependencies an
41+
required variables. As result you have ready to deploy image.
42+
43+
## Supported Variables
44+
45+
* **PROXY_TIMEOUT** - timeout in seconds for nginx proxy (default `90`)
46+
* **STATIC_URL** - url path for static files hosting (default `/static`)
47+
* **STATIC_PATH** - location on the file system where nginx should find static files (`/srv/static`)
48+
* **MEDIA_PATH** - location on the file system where nginx should find media files (`/srv/media`)

0 commit comments

Comments
 (0)