File tree Expand file tree Collapse file tree 8 files changed +128
-0
lines changed Expand file tree Collapse file tree 8 files changed +128
-0
lines changed Original file line number Diff line number Diff line change 1+ .DS_Store
2+ .gitignore
Original file line number Diff line number Diff line change 1+ FROM ubuntu:16.04
2+
3+ MAINTAINER Dockerfiles
4+
5+ # Install required packages and remove the apt packages cache when done.
6+
7+ RUN apt-get update && \
8+ apt-get upgrade -y && \
9+ apt-get install -y \
10+ git \
11+ python3 \
12+ python3-dev \
13+ python3-setuptools \
14+ python3-pip \
15+ nginx \
16+ supervisor \
17+ sqlite3 && \
18+ pip3 install -U pip setuptools && \
19+ rm -rf /var/lib/apt/lists/*
20+
21+ # install uwsgi now because it takes a little while
22+ RUN pip3 install uwsgi
23+
24+ # setup all the configfiles
25+ RUN echo "daemon off;" >> /etc/nginx/nginx.conf
26+ COPY nginx-app.conf /etc/nginx/sites-available/default
27+ COPY supervisor-app.conf /etc/supervisor/conf.d/
28+
29+ # COPY requirements.txt and RUN pip install BEFORE adding the rest of your code, this will cause Docker's caching mechanism
30+ # to prevent re-installing (all your) dependencies when you made a change a line or two in your app.
31+
32+ COPY app/requirements.txt /home/docker/code/app/
33+ RUN pip3 install -r /home/docker/code/app/requirements.txt
34+
35+ # add (the rest of) our code
36+ COPY . /home/docker/code/
37+
38+ EXPOSE 80
39+ CMD ["supervisord" , "-n" ]
Original file line number Diff line number Diff line change 1+ # nginx-app.conf
2+
3+ # the upstream component nginx needs to connect to
4+ upstream django {
5+ server unix:/home/docker/code/app.sock; # for a file socket
6+ # server 127.0.0.1:8001; # for a web port socket (we'll use this first)
7+ }
8+
9+ # configuration of the server
10+ server {
11+ # the port your site will be served on, default_server indicates that this server block
12+ # is the block to use if no blocks match the server_name
13+ listen 80 default_server;
14+
15+ # the domain name it will serve for
16+ server_name .example.com; # substitute your machine's IP address or FQDN
17+ charset utf-8;
18+
19+ # max upload size
20+ client_max_body_size 75M; # adjust to taste
21+
22+ # Django media
23+ location /media {
24+ alias /home/docker/persistent/media; # your Django project's media files - amend as required
25+ }
26+
27+ location /static {
28+ alias /home/docker/volatile/static; # your Django project's static files - amend as required
29+ }
30+
31+ # Finally, send all non-media requests to the Django server.
32+ location / {
33+ uwsgi_pass django;
34+ include /home/docker/code/uwsgi_params; # the uwsgi_params file you installed
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ [program:app-uwsgi]
2+ command = /usr/local/bin/uwsgi --ini /home/docker/code/uwsgi.ini
3+
4+ [program:nginx-app]
5+ command = /usr/sbin/nginx
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ uwsgi_param QUERY_STRING $query_string;
2+ uwsgi_param REQUEST_METHOD $request_method;
3+ uwsgi_param CONTENT_TYPE $content_type;
4+ uwsgi_param CONTENT_LENGTH $content_length;
5+
6+ uwsgi_param REQUEST_URI $request_uri;
7+ uwsgi_param PATH_INFO $document_uri;
8+ uwsgi_param DOCUMENT_ROOT $document_root;
9+ uwsgi_param SERVER_PROTOCOL $server_protocol;
10+ uwsgi_param HTTPS $https if_not_empty;
11+
12+ uwsgi_param REMOTE_ADDR $remote_addr;
13+ uwsgi_param REMOTE_PORT $remote_port;
14+ uwsgi_param SERVER_PORT $server_port;
15+ uwsgi_param SERVER_NAME $server_name;
You can’t perform that action at this time.
0 commit comments