# Django stuff:
*.log
+#uwsgi
+*.pid
+
# Sphinx documentation
docs/_build/
-FROM ubuntu:16.04
+FROM ubuntu:16.04
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN apt-get update
-RUN apt-get install -y npm git python-pip
+RUN apt-get install -y npm git python-pip nginx supervisor
RUN npm install -g bower
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN bower install --allow-root
RUN pip install -r requirements.txt
+RUN pip install uwsgi
+RUN echo "daemon off;" >> /etc/nginx/nginx.conf
+COPY nginx-app.conf /etc/nginx/sites-available/default
+COPY supervisor-app.conf /etc/supervisor/conf.d/
# delete the copy of the database inside the container (if exists)
RUN rm -f db.sqlite3
+ENV DJANGO_ENV=prod
RUN python manage.py makemigrations authosm
RUN python manage.py migrate
+RUN python manage.py collectstatic --noinput
EXPOSE 80
-CMD ["python", "manage.py", "runserver", "0.0.0.0:80"]
+
+CMD ["supervisord", "-n"]
\ No newline at end of file
--- /dev/null
+[uwsgi]
+module = sf_t3d.wsgi:application
+master = true
+pidfile = django.uwsgi.pid
+enable-threads = true
+http = 127.0.0.1:8000
+processes = 5
+# respawn processes taking more than 50 seconds
+harakiri = 50
+# respawn processes after serving 5000 requests
+max-requests = 5000
+# clear environment on exit
+vacuum = true
+# optional path to a virtualenv
+#home = env
+# background the process
+daemonize = django.uwsgi.log
\ No newline at end of file
--- /dev/null
+# nginx-app.conf
+
+# configuration of the server
+server {
+
+ listen 80;
+
+ charset utf-8;
+
+ # max upload size
+ client_max_body_size 75M;
+
+ location /static/ {
+ alias /usr/src/app/static/;
+ }
+
+ location / {
+ proxy_pass http://localhost:8000;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ }
+
+ # -----------
+ # Enable GZIP
+ # -----------
+ gzip on;
+ gzip_disable "msie6";
+ gzip_vary on;
+ gzip_types text/plain
+ text/css
+ application/json
+ application/javascript
+ application/x-javascript
+ text/xml
+ application/xml
+ application/xml+rss
+ text/javascript
+ image/svg+xml;
+ gzip_proxied any;
+ gzip_comp_level 6;
+ gzip_buffers 16 8k;
+ gzip_http_version 1.0;
+
+ # ------------
+ # Cache assets
+ # ------------
+# location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css
+# |rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz
+# |gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi
+# |wav|bmp|rtf)$ {
+# expires max;
+# log_not_found off;
+# access_log off;
+# }
+}
\ No newline at end of file
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'o5+o2jv(3-dqr(&ia#-@79cgr%xi*s+6xjws^8cxp211ge#buf'
-
-# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
-
-ALLOWED_HOSTS = []
+if os.getenv('DJANGO_ENV') == 'prod':
+ DEBUG = False
+else:
+ DEBUG = True
+ print DEBUG
+ALLOWED_HOSTS = ['*']
AUTH_USER_MODEL = "authosm.OsmUser"
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
-
-STATICFILES_FINDERS = (
- 'django.contrib.staticfiles.finders.FileSystemFinder',
- 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
- 'django.contrib.staticfiles.finders.DefaultStorageFinder'
-)
-
-STATICFILES_DIRS = (
- # Put strings here, like "/home/html/static" or "C:/www/django/static".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
- os.path.join(BASE_DIR, "static"),
-)
+if DEBUG:
+ STATICFILES_FINDERS = (
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+ 'django.contrib.staticfiles.finders.DefaultStorageFinder'
+ )
+ STATICFILES_DIRS = (
+ # Put strings here, like "/home/html/static" or "C:/www/django/static".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+ os.path.join(BASE_DIR, "static"),
+ )
+else:
+ STATIC_ROOT = os.path.join(BASE_DIR, "static/")
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
-)
\ No newline at end of file
+)
--- /dev/null
+[program:app-uwsgi]
+command = /usr/local/bin/uwsgi --ini /usr/src/app/django.ini
+environment=DJANGO_ENV="prod"
+
+[program:nginx-app]
+command = /usr/sbin/nginx
\ No newline at end of file