├── dddemo ├── __init__.py ├── static │ ├── js │ │ └── app.js │ └── scss │ │ └── master.scss ├── settings │ ├── local.template │ ├── __init__.py │ └── base.py ├── templates │ ├── home.html │ ├── 404.html │ └── base.html ├── wsgi.py └── urls.py ├── requirements.txt ├── manage.py ├── .gitignore ├── docker-utils ├── entrypoint.sh ├── app-start.sh ├── ssl │ ├── server.csr │ ├── server.crt │ └── server.key └── nginx │ └── default.template.conf ├── README.md ├── docker-compose.yml └── Dockerfile /dddemo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dddemo/static/js/app.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dddemo/settings/local.template: -------------------------------------------------------------------------------- 1 | """ 2 | To be used for local development only 3 | """ 4 | from dddemo.settings.base import * 5 | -------------------------------------------------------------------------------- /dddemo/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 | HOMEPAGE 5 | {% endblock content %} 6 | -------------------------------------------------------------------------------- /dddemo/settings/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from dddemo.settings.local import * 3 | except ImportError: 4 | from dddemo.settings.base import * 5 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Django==1.10.5 2 | Pillow==4.1.1 3 | django-extensions==1.7.9 4 | django-htmlmin==0.10.0 5 | django-compressor==2.1.1 6 | psycopg2==2.7.1 7 | dj-database-url==0.4.2 8 | six>=1.10.0 9 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | # test 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dddemo.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #* 2 | *$ 3 | *.BAK 4 | *.Z 5 | *.bak 6 | *.class 7 | *.dylib 8 | *.elc 9 | *.ln 10 | *.log 11 | *.o 12 | *.obj 13 | *.olb 14 | *.old 15 | *.orig 16 | *.pyc 17 | *.pyo 18 | *.rej 19 | */.git/* 20 | *~ 21 | ,* 22 | .#* 23 | .DS_Store 24 | .del-* 25 | .make.state 26 | .nse_depinfo 27 | CVS.adm 28 | RCS 29 | RCSLOG 30 | SCCS 31 | _$* 32 | node_modules/ 33 | .sass-cache 34 | */settings/local.py 35 | docker-compose.override.yml 36 | -------------------------------------------------------------------------------- /docker-utils/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eoux pipefail 4 | 5 | if [ "$1" == 'init' ]; then 6 | echo "Run Migrations" 7 | ${SITE_DIR}/env/bin/python ${SITE_DIR}/proj/manage.py migrate 8 | ${SITE_DIR}/env/bin/python ${SITE_DIR}/proj/manage.py collectstatic 9 | elif [ "$1" == 'manage' ]; then 10 | shift 11 | echo "Manage.py $@" 12 | ${SITE_DIR}/env/bin/python ${SITE_DIR}/proj/manage.py $@ 13 | else 14 | exec "$@" 15 | fi 16 | -------------------------------------------------------------------------------- /dddemo/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for dddemo project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dddemo.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /dddemo/static/scss/master.scss: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0px; 3 | header { 4 | h1 { 5 | margin: 0px; 6 | padding: 5px; 7 | } 8 | background-color: #aaa; 9 | } 10 | 11 | #content { 12 | padding: 5px; 13 | } 14 | 15 | footer { 16 | position:absolute; 17 | bottom:0; 18 | width:100%; 19 | height:45px; 20 | padding: 5px; 21 | background-color: #333; 22 | color: white; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /dddemo/templates/404.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Page Not Found{% endblock %} 4 | 5 | {% block content %} 6 | 9 | 10 | 18 | {% endblock content %} 19 | -------------------------------------------------------------------------------- /docker-utils/app-start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Starting uWSGI for ${PROJECT_NAME}" 4 | 5 | $SITE_DIR/env/bin/uwsgi --chdir ${SITE_DIR}proj/ \ 6 | --module=${PROJECT_NAME}.wsgi:application \ 7 | --master \ 8 | --env DJANGO_SETTINGS_MODULE=${PROJECT_NAME}.settings \ 9 | --vacuum \ 10 | --max-requests=5000 \ 11 | --virtualenv ${SITE_DIR}env/ \ 12 | --socket 0.0.0.0:8000 \ 13 | --processes $NUM_PROCS \ 14 | --threads $NUM_THREADS \ 15 | --python-autoreload=1 16 | 17 | # --static-map /static=${SITE_DIR}htdocs/static/ \ 18 | # --static-map /media=${SITE_DIR}htdocs/media/ \ 19 | -------------------------------------------------------------------------------- /docker-utils/ssl/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBhDCB7gIBADBFMQswCQYDVQQGEwJVUzETMBEGA1UECBMKU29tZS1TdGF0ZTEh 3 | MB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEB 4 | AQUAA4GNADCBiQKBgQDIPeJtcsy32//TXxahLXrg15k7jEP6PZVcQUzGsinSy+ON 5 | 2/u1UTqgSnVBZ/hOy3qJDHaSJi0Ij8ve9JJUnKe3MlFU3CXByfsbiQPRU/CeLaLf 6 | zKkhJ6kM0VDjC4SRBu1vKC5wAtHvyRCNKN1S6LIh3SvuKDWW6o9+Rxh7LD9LvwID 7 | AQABoAAwDQYJKoZIhvcNAQEFBQADgYEAmhOdPzCpRd3/scW62EJ3Cx7xq45jp7fu 8 | CaSlb+sc592xlscrVBKs+lGXRJOzZb5sYfFFIZOY7yHnVaewvHdxxxAmmON6xtB9 9 | s9yEw0CdGAxD1nEdUsXhTRhsT0sKK04GBwQtqwH69RF1vJ18chZb5RhYHkJ6tZlZ 10 | 7xvMrOfD+MQ= 11 | -----END CERTIFICATE REQUEST----- 12 | -------------------------------------------------------------------------------- /docker-utils/ssl/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICAzCCAWwCCQDqcy9k1BAzLTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJV 3 | UzETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0 4 | cyBQdHkgTHRkMCAXDTE3MDIwMjAzMDg1OFoYDzIxOTYwNzA3MDMwODU4WjBFMQsw 5 | CQYDVQQGEwJVUzETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu 6 | ZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI 7 | PeJtcsy32//TXxahLXrg15k7jEP6PZVcQUzGsinSy+ON2/u1UTqgSnVBZ/hOy3qJ 8 | DHaSJi0Ij8ve9JJUnKe3MlFU3CXByfsbiQPRU/CeLaLfzKkhJ6kM0VDjC4SRBu1v 9 | KC5wAtHvyRCNKN1S6LIh3SvuKDWW6o9+Rxh7LD9LvwIDAQABMA0GCSqGSIb3DQEB 10 | BQUAA4GBACP+181OQpfYXe2SFDdIlE40kpw+NV9ZyREAk12Jop8gw/AIfzHWMNUX 11 | iUvfP7t/9lc0Vf1WZSuOt56td0XCIY1OeOwrwI+o8c6JkjSCYF30jM7dIszUlYO+ 12 | Wqa6/NPXv3EzPoLsvHr903gv1u04HdL2aAOvAzzNC2msBZX7/8nD 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /docker-utils/ssl/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQDIPeJtcsy32//TXxahLXrg15k7jEP6PZVcQUzGsinSy+ON2/u1 3 | UTqgSnVBZ/hOy3qJDHaSJi0Ij8ve9JJUnKe3MlFU3CXByfsbiQPRU/CeLaLfzKkh 4 | J6kM0VDjC4SRBu1vKC5wAtHvyRCNKN1S6LIh3SvuKDWW6o9+Rxh7LD9LvwIDAQAB 5 | AoGBAL6Un7f5pjxrh+3+N4SJy8TJjk7trhkymcBnahJGqaW2ZkqzD7s/p2O92iG5 6 | OcyMv4BGu2dYLE5Uxf3ampcrTjdPlqetEJ3M2cwWThVAHsL6Q2Cv48ThsXEUy0hR 7 | zyEvBuPh6PINHfg2Rs1QtP51stmGm6eiouLgXr8hOGwxtiEZAkEA7WbWr96+0K7W 8 | PO+ZEUniRbJI8hyiCF8cHAnoYkE9Ia75idYao5hwS5/TylpL6IrRD4TbgvkZxIMo 9 | AxnM7F2IlQJBANftyqO90h+lLBWpHCZZQBDGdKb5NKdQMzpoeBGp/H7nvfOxWY3M 10 | kBDeFzKQDJ/njkt4crHuvJP/VCTUTp71agMCQHNfqTJrhDyS25ddsfwO9iJ9FKpl 11 | c/Gxl02hGwi1P+pgyPFN1kBvUxPNpvYOkBmBbTyniq7KNNWmEAoBve+ZPUkCQQCf 12 | JMVLNWYeqK/7Lu5uXS1Yr8veHKHwBq4bCFAmRLCyH77iUv38Ap7Tr7xNKdoEKLe5 13 | bAasmZYnRfIQSuG/SoVdAkBF/utStQwA+skVvuL0Ii+2C17zIqJd4Bw6rotwxmzZ 14 | ESmCPKiw/17DDUt5JQDfh0hqC4pC38lbiaKHJrfCfi+Z 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /dddemo/urls.py: -------------------------------------------------------------------------------- 1 | """dddemo URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.11/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url 17 | from django.contrib import admin 18 | from django.views.generic.base import TemplateView 19 | 20 | urlpatterns = [ 21 | url(r'^admin/', admin.site.urls), 22 | url(r'^$', TemplateView.as_view(template_name="home.html"), name="home") 23 | ] 24 | -------------------------------------------------------------------------------- /dddemo/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load staticfiles compress %} 2 | 3 | 4 | 5 | Django Docker Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | {% compress css %} 16 | 17 | {% endcompress %} 18 | 19 | 20 | 21 |
22 |

Docker Demo

23 |
24 | 25 |
26 | {% block content %} 27 | {% endblock content %} 28 |
29 | 30 | 33 | 34 | 35 | 36 | 37 | {% block js_footer %}{% endblock %} 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a complete working demo of docker compose working with a django project. 2 | 3 | Features: 4 | - split into nginx/postgres/app containers 5 | - configuration is set by environment variables 6 | - changes to the django app will auto-reload the uwsgi process 7 | 8 | # DOCKER COMPOSE 9 | 10 | Build and start the app: 11 | 12 | docker-compose up 13 | # Or to rebuild 14 | docker-compose up --build 15 | 16 | # migrate and collectstatic 17 | docker-compose run app init 18 | 19 | # create admin user 20 | docker-compose run app manage createsuperuser 21 | 22 | Other helpful commands 23 | 24 | # enter db 25 | docker-compose run app manage dbshell 26 | 27 | # run any management command 28 | docker-compose run app manage 29 | 30 | # enter bash shell 31 | docker-compose run app /bin/bash 32 | 33 | # stop everything 34 | docker-compose stop 35 | 36 | # stop everything, destroy containers, and volumes 37 | docker-compose down 38 | 39 | Override the default docker compose variables 40 | 41 | # vim docker-compose.override.yml 42 | version: '3' 43 | services: 44 | web: 45 | ports: 46 | - 8000:80 47 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | db: 5 | image: postgres:9.6 6 | container_name: dddemo-postgres 7 | ports: 8 | - "5432" 9 | networks: 10 | - jaz 11 | 12 | app: 13 | build: 14 | context: . 15 | dockerfile: Dockerfile 16 | container_name: dddemo-app 17 | command: /site/docker-utils/app-start.sh 18 | volumes: 19 | - .:/site/proj/ 20 | - static-volume:/site/htdocs/static/ 21 | ports: 22 | - "8000" 23 | environment: 24 | - DATABASE_URL=postgres://postgres@db/postgres 25 | - SITE_DIR=/site/ 26 | - PROJECT_NAME=dddemo 27 | - DJANGO_DEBUG=True 28 | networks: 29 | - jaz 30 | 31 | web: 32 | image: nginx:1.11 33 | container_name: dddemo-web 34 | ports: 35 | - "80:80" 36 | - "443:443" 37 | depends_on: 38 | - app 39 | volumes: 40 | - ./docker-utils/nginx/default.template.conf:/root/default.template.conf 41 | - ./docker-utils/ssl/:/site/ssl/ 42 | - static-volume:/static 43 | command: /bin/bash -c "envsubst '$$NGINX_HTTP_PORT $$NGINX_HTTPS_PORT' < /root/default.template.conf > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" 44 | environment: 45 | - NGINX_HOST=foobar.com 46 | - NGINX_HTTP_PORT=80 47 | - NGINX_HTTPS_PORT=443 48 | networks: 49 | - jaz 50 | 51 | networks: 52 | jaz: 53 | 54 | volumes: 55 | static-volume: 56 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Debian based image 2 | FROM ubuntu:16.04 3 | # reduce image size by cleaning up after install 4 | RUN apt-get update && apt-get install -y \ 5 | build-essential \ 6 | git \ 7 | libjpeg-dev \ 8 | libfreetype6 \ 9 | libfreetype6-dev \ 10 | libpq-dev \ 11 | postgresql-client \ 12 | python-dev \ 13 | python-virtualenv \ 14 | zlib1g-dev \ 15 | ruby-sass \ 16 | && rm -rf /var/lib/apt/lists/* 17 | 18 | # set the environment variable default; can be overridden by compose 19 | ENV SITE_DIR=/site/ 20 | RUN mkdir -p $SITE_DIR 21 | WORKDIR $SITE_DIR 22 | RUN mkdir -p proj/ var/log/ htdocs/ 23 | 24 | # create a virtualenv to separate app packages from system packages 25 | RUN virtualenv env/ 26 | COPY docker-utils/ssl/ ssl/ 27 | 28 | # pre-install requirements; doing this sooner prevents unnecessary layer-building 29 | COPY requirements.txt requirements.txt 30 | RUN env/bin/pip install -r requirements.txt 31 | 32 | # Make sure that we install uwsgi, regardless of project requirements 33 | RUN env/bin/pip install uwsgi 34 | 35 | # Set some environment variables; can be overridden by compose 36 | ENV NUM_THREADS=2 37 | ENV NUM_PROCS=2 38 | ENV DJANGO_DATABASE_URL=postgres://postgres@db/postgres 39 | 40 | # Copy in docker scripts 41 | COPY docker-utils/ docker-utils/ 42 | 43 | # Copy in project files 44 | COPY . proj/ 45 | 46 | EXPOSE 8000 47 | 48 | # Set a custom entrypoint to let us provide custom initialization behavior 49 | ENTRYPOINT ["./docker-utils/entrypoint.sh"] 50 | 51 | # Set the command to start uwsgi 52 | CMD ["./docker-utils/app-start.sh"] 53 | -------------------------------------------------------------------------------- /docker-utils/nginx/default.template.conf: -------------------------------------------------------------------------------- 1 | 2 | send_timeout 60s; 3 | client_max_body_size 60m; 4 | 5 | upstream app_server { 6 | server app:8000 weight=10 max_fails=3 fail_timeout=30s; 7 | } 8 | 9 | server { 10 | listen ${NGINX_HTTP_PORT}; 11 | 12 | location /static/ { 13 | autoindex on; 14 | alias /static/; 15 | } 16 | 17 | location / { 18 | try_files $uri @proxy_to_app; 19 | } 20 | 21 | location @proxy_to_app { 22 | 23 | uwsgi_param Host $http_host; 24 | uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for; 25 | uwsgi_param X-Real-IP $remote_addr; 26 | uwsgi_param X-Scheme $scheme; 27 | uwsgi_read_timeout 120s; 28 | uwsgi_send_timeout 120s; 29 | uwsgi_pass app_server; 30 | include uwsgi_params; 31 | } 32 | } 33 | 34 | server { 35 | listen ${NGINX_HTTPS_PORT} ssl http2; 36 | 37 | ssl_certificate /site/ssl/server.crt; 38 | ssl_certificate_key /site/ssl/server.key; 39 | ssl_session_timeout 1d; 40 | ssl_session_cache shared:SSL:50m; 41 | ssl_session_tickets off; 42 | 43 | # modern configuration. tweak to your needs. 44 | ssl_protocols TLSv1.2; 45 | ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; 46 | ssl_prefer_server_ciphers on; 47 | 48 | location /static/ { 49 | autoindex on; 50 | alias /static/; 51 | } 52 | 53 | location / { 54 | try_files $uri @proxy_to_app; 55 | } 56 | 57 | location @proxy_to_app { 58 | 59 | uwsgi_param Host $http_host; 60 | uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for; 61 | uwsgi_param X-Real-IP $remote_addr; 62 | uwsgi_param X-Scheme $scheme; 63 | uwsgi_read_timeout 120s; 64 | uwsgi_send_timeout 120s; 65 | uwsgi_pass app_server; 66 | include uwsgi_params; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /dddemo/settings/base.py: -------------------------------------------------------------------------------- 1 | # Django settings for joejasinski project. 2 | import os 3 | import sys 4 | import dj_database_url 5 | gettext = lambda s: s 6 | 7 | 8 | def env(key, default=None): 9 | """Retrieves env vars and makes Python boolean replacements""" 10 | val = os.getenv(key, default) 11 | 12 | if val == 'True': 13 | val = True 14 | elif val == 'False': 15 | val = False 16 | return val 17 | 18 | 19 | def env_list(key, default=""): 20 | val = os.getenv(key, default) 21 | return val.split(",") 22 | 23 | 24 | PROJECT_DIR = env( 25 | "DJANGO_PROJECT_DIR", 26 | os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) 27 | 28 | SITE_DIR = env( 29 | "SITE_DIR", 30 | os.path.abspath(os.path.join(PROJECT_DIR, '..', '..', '..'))) 31 | 32 | 33 | sys.path.insert(0, os.path.join(PROJECT_DIR, 'apps', )) 34 | 35 | DEBUG = env("DJANGO_DEBUG", False) 36 | TEMPLATE_DEBUG = DEBUG 37 | 38 | ADMINS = ( 39 | # ('Your Name', 'your_email@example.com'), 40 | ) 41 | 42 | MANAGERS = ADMINS 43 | 44 | 45 | # FORMAT: postgres://USER:PASSWORD@HOST:PORT/NAME 46 | DATABASES = {'default': dj_database_url.parse(env("DJANGO_DATABASE_URL", "postgres://user:pass@localhost:/database"))} 47 | 48 | # Hosts/domain names that are valid for this site; required if DEBUG is False 49 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts 50 | ALLOWED_HOSTS = env_list("DJANGO_ALLOWED_HOSTS", '*') 51 | 52 | # Local time zone for this installation. Choices can be found here: 53 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 54 | # although not all choices may be available on all operating systems. 55 | # In a Windows environment this must be set to your system time zone. 56 | TIME_ZONE = 'America/Chicago' 57 | 58 | # Language code for this installation. All choices can be found here: 59 | # http://www.i18nguy.com/unicode/language-identifiers.html 60 | LANGUAGE_CODE = 'en-us' 61 | 62 | LANGUAGES = ( 63 | ('en-us', 'English'), 64 | ) 65 | 66 | SITE_ID = 1 67 | 68 | # If you set this to False, Django will make some optimizations so as not 69 | # to load the internationalization machinery. 70 | USE_I18N = True 71 | 72 | # If you set this to False, Django will not format dates, numbers and 73 | # calendars according to the current locale. 74 | USE_L10N = True 75 | 76 | # If you set this to False, Django will not use timezone-aware datetimes. 77 | USE_TZ = True 78 | 79 | # Absolute filesystem path to the directory that will hold user-uploaded files. 80 | # Example: "/var/www/example.com/media/" 81 | MEDIA_ROOT = env( 82 | "DJANGO_MEDIA_ROOT", 83 | os.path.abspath(os.path.join(SITE_DIR, 'htdocs', 'media'))) 84 | 85 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a 86 | # trailing slash. 87 | # Examples: "http://example.com/media/", "http://media.example.com/" 88 | MEDIA_URL = '/media/' 89 | 90 | # Absolute path to the directory static files should be collected to. 91 | # Don't put anything in this directory yourself; store your static files 92 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. 93 | # Example: "/var/www/example.com/static/" 94 | STATIC_ROOT = env( 95 | "DJANGO_STATIC_ROOT", 96 | os.path.abspath(os.path.join(SITE_DIR, 'htdocs', 'static'))) 97 | 98 | # URL prefix for static files. 99 | # Example: "http://example.com/static/", "http://static.example.com/" 100 | STATIC_URL = '/static/' 101 | 102 | # Additional locations of static files 103 | STATICFILES_DIRS = ( 104 | # Put strings here, like "/home/html/static" or "C:/www/django/static". 105 | # Always use forward slashes, even on Windows. 106 | # Don't forget to use absolute paths, not relative paths. 107 | os.path.join(PROJECT_DIR, 'static'), 108 | ) 109 | 110 | TEST_RUNNER = 'django.test.runner.DiscoverRunner' 111 | 112 | # List of finder classes that know how to find static files in 113 | # various locations. 114 | STATICFILES_FINDERS = ( 115 | 'django.contrib.staticfiles.finders.FileSystemFinder', 116 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 117 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', 118 | 'compressor.finders.CompressorFinder', 119 | ) 120 | 121 | # Make this unique, and don't share it with anybody. 122 | SECRET_KEY = env( 123 | "DJANGO_SECRET_KEY", '1s(wsqn%(gvu92f%%l2(vwaiewz_6xnx&9v15z^40-jq3&0%)0') 124 | 125 | 126 | TEMPLATES = [ 127 | { 128 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 129 | 'DIRS': [os.path.join(PROJECT_DIR, 'templates')], 130 | 'APP_DIRS': True, 131 | 'OPTIONS': { 132 | 'context_processors': [ 133 | 'django.contrib.auth.context_processors.auth', 134 | 'django.contrib.messages.context_processors.messages', 135 | 'django.template.context_processors.i18n', 136 | 'django.template.context_processors.request', 137 | 'django.template.context_processors.media', 138 | 'django.template.context_processors.static', 139 | ], 140 | }, 141 | }, 142 | ] 143 | 144 | MIDDLEWARE_CLASSES = ( 145 | 'django.middleware.common.CommonMiddleware', 146 | 'htmlmin.middleware.HtmlMinifyMiddleware', 147 | 'django.contrib.sessions.middleware.SessionMiddleware', 148 | 'django.middleware.csrf.CsrfViewMiddleware', 149 | 'django.middleware.locale.LocaleMiddleware', 150 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 151 | 'django.contrib.messages.middleware.MessageMiddleware', 152 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 153 | 'django.middleware.security.SecurityMiddleware', 154 | 155 | 'htmlmin.middleware.MarkRequestMiddleware', 156 | ) 157 | 158 | SECURE_BROWSER_XSS_FILTER = True 159 | SECURE_CONTENT_TYPE_NOSNIFF = True 160 | 161 | COMPRESS_ENABLED = True 162 | COMPRESS_PRECOMPILERS = ( 163 | ('text/x-sass', 'sass {infile} {outfile}'), 164 | ('text/x-scss', 'sass --scss {infile} {outfile}'), 165 | ) 166 | 167 | ROOT_URLCONF = 'dddemo.urls' 168 | 169 | # Python dotted path to the WSGI application used by Django's runserver. 170 | WSGI_APPLICATION = 'dddemo.wsgi.application' 171 | 172 | 173 | HTML_MINIFY = True 174 | EXCLUDE_FROM_MINIFYING = ('^files/', '^admin/', '^media/') 175 | 176 | INSTALLED_APPS = ( 177 | 'django.contrib.auth', 178 | 'django.contrib.contenttypes', 179 | 'django.contrib.sessions', 180 | 'django.contrib.sites', 181 | 'django.contrib.messages', 182 | 'django.contrib.staticfiles', 183 | 'django.contrib.sitemaps', 184 | 'django.contrib.admin', 185 | 186 | 'django_extensions', 187 | 'compressor', 188 | 189 | ) 190 | 191 | CONTACT_EMAIL = "joe.jasinski@gmail.com" 192 | 193 | 194 | MIGRATION_MODULES = { 195 | } 196 | 197 | THUMBNAIL_HIGH_RESOLUTION = True 198 | --------------------------------------------------------------------------------