aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Dockerfile34
-rw-r--r--Dockerfile.web4
-rw-r--r--README3
-rw-r--r--docker/.gitconfig11
-rw-r--r--docker/README26
-rwxr-xr-xdocker/git-proxy12
-rwxr-xr-xdocker/migrate.sh2
-rw-r--r--docker/nginx.conf47
-rwxr-xr-xdocker/updatelayers.sh9
-rw-r--r--wsgi.py6
10 files changed, 154 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000000..1f63e2adeb
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,34 @@
+FROM buildpack-deps:latest
+MAINTAINER Michael Halstead <mhalstead@linuxfoundation.org>
+
+EXPOSE 80
+ENV PYTHONUNBUFFERED 1
+## Uncomment to set proxy ENVVARS within container
+#ENV http_proxy http://your.proxy.server:port
+#ENV https_proxy https://your.proxy.server:port
+
+RUN apt-get update
+RUN apt-get install -y --no-install-recommends \
+ python-pip \
+ python-mysqldb \
+ python-dev \
+ python-imaging \
+ netcat-openbsd \
+ vim \
+ && rm -rf /var/lib/apt/lists/*
+RUN pip install --upgrade pip
+RUN pip install gunicorn
+CMD mkdir /opt/workdir
+ADD . /opt/layerindex
+RUN pip install -r /opt/layerindex/requirements.txt
+ADD settings.py /opt/layerindex/settings.py
+ADD docker/updatelayers.sh /opt/updatelayers.sh
+ADD docker/migrate.sh /opt/migrate.sh
+
+## Uncomment to add a .gitconfig file within container
+#ADD docker/.gitconfig /root/.gitconfig
+## Uncomment to add a proxy script within container, if you choose to
+## do so, you will also have to edit .gitconfig appropriately
+#ADD docker/git-proxy /opt/bin/git-proxy
+
+CMD ["/usr/local/bin/gunicorn", "wsgi:application", "--workers=4", "--bind=:5000", "--log-level=debug", "--chdir=/opt/layerindex"]
diff --git a/Dockerfile.web b/Dockerfile.web
new file mode 100644
index 0000000000..0b9e2c2458
--- /dev/null
+++ b/Dockerfile.web
@@ -0,0 +1,4 @@
+FROM nginx:latest
+MAINTAINER Michael Halstead <mhalstead@linuxfoundation.org>
+COPY docker/nginx.conf /etc/nginx/nginx.conf
+COPY layerindex/static /usr/share/nginx/html/static
diff --git a/README b/README
index 1903fbfa4d..84edee2fd5 100644
--- a/README
+++ b/README
@@ -107,6 +107,9 @@ Setup instructions:
* templates/base.html
* templates/layerindex/about.html
+7. To use layerindex-web with Docker containers, refer to docker/README
+ keeping in mind you'll need to set up Docker properly as part of the
+ setup process.
Usage
-----
diff --git a/docker/.gitconfig b/docker/.gitconfig
new file mode 100644
index 0000000000..f3ab3722cf
--- /dev/null
+++ b/docker/.gitconfig
@@ -0,0 +1,11 @@
+# This .gitconfig file resides in /root/ in the "layersapp" container
+# add any settings you'd like to have in there, such as proxy servers
+[http]
+ #proxy = http://your.proxy.server:port
+[https]
+ #proxy = https://your.proxy.server:port
+[core]
+ # Optional: uncomment this line if you want to use a proxy script
+ #gitproxy = /opt/bin/git-proxy
+[socks]
+ #proxy = your.socks.proxy:port
diff --git a/docker/README b/docker/README
new file mode 100644
index 0000000000..14bc392fd9
--- /dev/null
+++ b/docker/README
@@ -0,0 +1,26 @@
+## This is set up to make a cluster of three containers. First we build two from the root of the repo.
+docker build -t halstead/layerindex-app .
+docker build -t halstead/layerindex-web -f Dockerfile.web .
+
+## Start a database server. We use MariaDB in production.
+## In order to configure your settings.py file to use this database server, use:
+## 'ENGINE': 'django.db.backends.mysql',
+## 'NAME': 'layersdb',
+## 'USER': 'root',
+## 'PASSWORD': 'testingpw',
+## 'HOST': 'layersdb',
+## 'PORT': '',
+docker run -d --name layerdb -e MYSQL_ROOT_PASSWORD=testingpw -e MYSQL_DATABASE=layersdb mariadb
+
+## If you have a copy of the the production data now is the time to insert it.
+## If not you can skip the next step for a clean install.
+xzcat ./layerdb.sql.xz | docker run -i --link layerdb:layersdb --rm mariadb sh -c 'exec mysql -hlayersdb -uroot -p"testingpw" layersdb'
+
+docker run -d --link layerdb:layersdb --name layersapp halstead/layerindex-app
+docker run -d --link layersapp:layersapp --name layersweb -p 49153:80 halstead/layerindex-web
+
+## To apply layerindex migration
+docker run --rm --link layerdb:layersdb halstead/layerindex-app /opt/migrate.sh
+
+## To update the layer info we can run the job in a temporary container.
+docker run --rm --link layerdb:layersdb halstead/layerindex-app /opt/updatelayers.sh
diff --git a/docker/git-proxy b/docker/git-proxy
new file mode 100755
index 0000000000..9fd844e981
--- /dev/null
+++ b/docker/git-proxy
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# This simple proxy script (for git) resides at /opt/bin in the layersapp
+# container. If you use it, uncomment the appropriate line in .gitproxy
+# this method has been tested using a socks proxy
+PROXY=your.proxy.server
+PORT=portnumber
+
+METHOD="-X 5 -x ${PROXY}:${PORT}"
+
+# BSD netcat is used to connect
+/bin/nc $METHOD $*
diff --git a/docker/migrate.sh b/docker/migrate.sh
new file mode 100755
index 0000000000..ea394c339b
--- /dev/null
+++ b/docker/migrate.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+python /opt/layerindex/manage.py migrate layerindex
diff --git a/docker/nginx.conf b/docker/nginx.conf
new file mode 100644
index 0000000000..7afc3a80b9
--- /dev/null
+++ b/docker/nginx.conf
@@ -0,0 +1,47 @@
+#daemon off; ##Included in CMD
+error_log /dev/stdout info;
+worker_processes 1;
+
+# user nobody nogroup;
+pid /tmp/nginx.pid;
+
+events {
+ worker_connections 1024;
+ accept_mutex off;
+}
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+ access_log /dev/stdout combined;
+ sendfile on;
+
+ upstream app_server {
+ # For a TCP configuration:
+ server layersapp:5000 fail_timeout=0;
+ }
+
+ server {
+ listen 80 default;
+ client_max_body_size 4G;
+ server_name _;
+
+ keepalive_timeout 5;
+
+ # path for static files
+ root /usr/share/nginx/html;
+
+ location / {
+ try_files $uri @proxy_to_app;
+ }
+
+ location @proxy_to_app {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect off;
+
+ proxy_pass http://app_server;
+ }
+
+ }
+}
diff --git a/docker/updatelayers.sh b/docker/updatelayers.sh
new file mode 100755
index 0000000000..50c73bfbd4
--- /dev/null
+++ b/docker/updatelayers.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+update=/opt/layerindex/layerindex/update.py
+$update -q -r
+$update -b jethro -x -r -q
+$update -b fido -x -r -q
+$update -b dizzy -x -r -q
+$update -b daisy -x -r -q
+$update -b dora -x -r -q
+$update -b dylan -x -r -q
diff --git a/wsgi.py b/wsgi.py
new file mode 100644
index 0000000000..99f0915afb
--- /dev/null
+++ b/wsgi.py
@@ -0,0 +1,6 @@
+import os, sys
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
+sys.path.append('/var/www/html/layerindex')
+
+from django.core.wsgi import get_wsgi_application
+application = get_wsgi_application()