Skip to content

Commit 871e91c

Browse files
committed
initial commit
0 parents  commit 871e91c

8 files changed

+128
-0
lines changed

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM stackbrew/debian:jessie
2+
MAINTAINER Matt Bentley <[email protected]>
3+
RUN (echo "deb http://http.debian.net/debian/ jessie main contrib non-free" > /etc/apt/sources.list && echo "deb http://http.debian.net/debian/ jessie-updates main contrib non-free" >> /etc/apt/sources.list && echo "deb http://security.debian.org/ jessie/updates main contrib non-free" >> /etc/apt/sources.list)
4+
RUN apt-get update
5+
6+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor
7+
RUN easy_install pip
8+
RUN pip install uwsgi
9+
10+
ADD . /opt/django/
11+
12+
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
13+
RUN rm /etc/nginx/sites-enabled/default
14+
RUN ln -s /opt/django/django.conf /etc/nginx/sites-enabled/
15+
RUN ln -s /opt/django/supervisord.conf /etc/supervisor/conf.d/
16+
17+
RUN pip install -r /opt/django/app/requirements.txt
18+
19+
VOLUME ["/opt/django/app"]
20+
EXPOSE 80
21+
CMD ["/opt/django/run.sh"]

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
mbentley/ubuntu-django-uwsgi-nginx
2+
==================
3+
4+
docker image for django (uwsgi) & nginx
5+
based off of stackbrew/ubuntu:12.04
6+
7+
To pull this image:
8+
`docker pull mbentley/ubuntu-django-uwsgi-nginx`
9+
10+
Example usage:
11+
`docker run -p 80 -d -e MODULE=myapp mbentley/ubuntu-django-uwsgi-nginx`
12+
13+
You can mount the application volume to run a specific application. The default volume inside in the container is `/opt/django/app`. Here is an example:
14+
`docker run -p 80 -d -e MODULE=myapp -v /home/mbentley/myapp:/opt/django/app mbentley/ubuntu-django-uwsgi-nginx`
15+
16+
By default, this just runs a default 'welcome to django' project.

app/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
django

django.conf

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
upstream django {
2+
server unix:/opt/django/app.sock;
3+
}
4+
5+
server {
6+
listen 80 default_server;
7+
charset utf-8;
8+
client_max_body_size 75M;
9+
10+
location /media {
11+
alias /opt/django/persistent/media; # your Django project's media files - amend as required
12+
}
13+
14+
location /static {
15+
alias /opt/django/volatile/static; # your Django project's static files - amend as required
16+
}
17+
18+
location / {
19+
uwsgi_pass django;
20+
include /opt/django/uwsgi_params; # the uwsgi_params file you installed
21+
}
22+
}

run.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
MODULE=${MODULE:-website}
4+
5+
sed -i "s#module=website.wsgi:application#module=${MODULE}.wsgi:application#g" /opt/django/uwsgi.ini
6+
7+
if [ ! -f "/opt/django/app/manage.py" ]
8+
then
9+
echo "creating basic django project (module: ${MODULE})"
10+
django-admin.py startproject ${MODULE} /opt/django/app/
11+
fi
12+
13+
/usr/bin/supervisord

supervisord.conf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:uwsgi]
5+
command = /usr/local/bin/uwsgi --ini /opt/django/uwsgi.ini --touch-reload /opt/django/reload
6+
7+
[program:nginx]
8+
command = /usr/sbin/nginx

uwsgi.ini

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[uwsgi]
2+
# this config will be loaded if nothing specific is specified
3+
# load base config from below
4+
ini = :base
5+
6+
# %d is the dir this configuration file is in
7+
socket = %dapp.sock
8+
master = true
9+
processes = 4
10+
11+
[dev]
12+
ini = :base
13+
# socket (uwsgi) is not the same as http, nor http-socket
14+
socket = :8001
15+
16+
17+
[local]
18+
ini = :base
19+
http = :8000
20+
# set the virtual env to use
21+
home=/Users/you/envs/env
22+
23+
24+
[base]
25+
# chdir to the folder of this config file, plus app/website
26+
chdir = %dapp/
27+
# load the module from wsgi.py, it is a python path from
28+
# the directory above.
29+
module=website.wsgi:application
30+
# allow anyone to connect to the socket. This is very permissive
31+
chmod-socket=666

uwsgi_params

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
uwsgi_param QUERY_STRING $query_string;
3+
uwsgi_param REQUEST_METHOD $request_method;
4+
uwsgi_param CONTENT_TYPE $content_type;
5+
uwsgi_param CONTENT_LENGTH $content_length;
6+
7+
uwsgi_param REQUEST_URI $request_uri;
8+
uwsgi_param PATH_INFO $document_uri;
9+
uwsgi_param DOCUMENT_ROOT $document_root;
10+
uwsgi_param SERVER_PROTOCOL $server_protocol;
11+
uwsgi_param HTTPS $https if_not_empty;
12+
13+
uwsgi_param REMOTE_ADDR $remote_addr;
14+
uwsgi_param REMOTE_PORT $remote_port;
15+
uwsgi_param SERVER_PORT $server_port;
16+
uwsgi_param SERVER_NAME $server_name;

0 commit comments

Comments
 (0)