Permalink
Browse files

Create simple dockerfile to run the sandbox

The container only runs an uwsgi process and uses the
default sandbox settings for now.
  • Loading branch information...
1 parent ca72d1d commit 40fbaa5a0f451ef54a9285b69511dbeadf3e3f15 @mvantellingen mvantellingen committed Nov 22, 2015
Showing with 90 additions and 1 deletion.
  1. +6 −0 .dockerignore
  2. +23 −0 Dockerfile
  3. +4 −1 Makefile
  4. +2 −0 requirements.txt
  5. +7 −0 sandbox.yml
  6. +3 −0 sites/sandbox/deploy/run_uwsgi.sh
  7. +34 −0 sites/sandbox/deploy/uwsgi.ini
  8. +11 −0 sites/sandbox/wsgi.py
View
@@ -0,0 +1,6 @@
+.cache
+.tox
+.tx
+__pycache__
+*.pyc
+node_modules/
View
@@ -0,0 +1,23 @@
+FROM python:2.7
+ENV PYTHONUNBUFFERED 1
+
+COPY ./requirements.txt /requirements.txt
+RUN pip install -r /requirements.txt
+
+RUN groupadd -r django && useradd -r -g django django
+COPY . /app
+RUN chown -R django /app
+
+WORKDIR /app
+
+
+RUN make install
+
+USER django
+
+RUN make build_sandbox
+
+RUN cp --remove-destination /app/src/oscar/static/oscar/img/image_not_found.jpg /app/sites/sandbox/public/media/
+RUN chmod +x /app/sites/sandbox/deploy/run_uwsgi.sh
+
+CMD /app/sites/sandbox/deploy/run_uwsgi.sh
View
@@ -1,5 +1,5 @@
# These targets are not files
-.PHONY: install sandbox docs coverage lint travis messages compiledmessages css clean preflight make_sandbox
+.PHONY: install sandbox docs coverage lint travis messages compiledmessages css clean preflight sandbox_image
install:
pip install -e . -r requirements.txt
@@ -24,6 +24,9 @@ build_sandbox:
sandbox: install build_sandbox
+sandbox_image:
+ docker build -t django-oscar-sandbox:latest .
+
docs:
cd docs && make html
View
@@ -14,6 +14,8 @@ Whoosh==2.6.0
pysolr==3.2.0
requests==2.7.0
uWSGI==2.0.11.2
+whitenoise==2.0.6
+Pillow==2.7.0
# Docs
Sphinx==1.2.3
View
@@ -0,0 +1,7 @@
+---
+sandbox:
+ build: .
+ ports:
+ - "8080:8080"
+ command:
+ - /app/sites/sandbox/deploy/run_uwsgi.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+set -e
+uwsgi --ini /app/sites/sandbox/deploy/uwsgi.ini
@@ -0,0 +1,34 @@
+[uwsgi]
+processes = 2
+http = :8080
+threads = 10
+vacuum = 1
+master = true
+enable-threads = true
+lazy = 1
+thunder-lock = 1
+buffer-size = 65535
+
+# Kill requests after 30 seconds
+harakiri = 30
+harakiri-verbose = true
+
+module = wsgi:application
+
+http-keepalive = true
+http-auto-chunked = true
+add-header = Connection: Keep-Alive
+
+static-map = /=%d../static/
+
+python-path = /app/sites/sandbox
+
+; if the client supports gzip encoding goto to the gzipper
+route-if = contains:${HTTP_ACCEPT_ENCODING};gzip goto:_gzip
+route-run = last:
+
+; pass the response to the gzip transformation
+route-label = _gzip
+route-run = gzip:
+route-run = chunked:
+route-run = last:
View
@@ -0,0 +1,11 @@
+# isort:skip
+import os
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
+
+from django.core.wsgi import get_wsgi_application # isort:skip
+from whitenoise.django import DjangoWhiteNoise # isort:skip
+
+
+application = get_wsgi_application()
+application = DjangoWhiteNoise(application)

0 comments on commit 40fbaa5

Please sign in to comment.