From 8754b779669f8c94fb9080c015a7b384724a1dd3 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 9 Apr 2015 12:13:17 -0700 Subject: [PATCH] Initial commit --- .gitignore | 1 + Dockerfile | 31 +++++++++++++++++++++++++++++++ cron.conf | 3 +++ default | 16 ++++++++++++++++ nginx.conf | 3 +++ streamrecord.conf | 4 ++++ streamrecord.ini | 18 ++++++++++++++++++ supervisor.conf | 3 +++ 8 files changed, 79 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 cron.conf create mode 100644 default create mode 100644 nginx.conf create mode 100644 streamrecord.conf create mode 100644 streamrecord.ini create mode 100644 supervisor.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6aa7334 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +streamrecord/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..394531c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM ubuntu:14.04 +MAINTAINER Dave P + +# Create user +RUN useradd --create-home --uid 1000 streamrecord ; \ + echo "streamrecord:streamrecord" | chpasswd ; \ + locale-gen en ; \ + sed -i 's/archive.ubuntu.com/mirror.math.ucdavis.edu/' /etc/apt/sources.list ; \ + apt-get update ; apt-get install -y vim nginx-full uwsgi uwsgi-plugin-python3 python3-cherrypy3 python3-jinja2 supervisor curl mkvtoolnix libav-tools cron ; \ + echo "daemon off;" >> /etc/nginx/nginx.conf ; \ + echo "* * * * * sleep 2 && curl -s http://127.0.0.1/api/tick > /dev/null" > /tmp/crontab ; \ + crontab -u streamrecord /tmp/crontab ; \ + rm /tmp/crontab ; \ + su -c "mkdir /home/streamrecord/app/" streamrecord + +# install configs +COPY default /etc/nginx/sites-available/default +COPY streamrecord.ini /etc/uwsgi/apps-enabled/streamrecord.ini +COPY nginx.conf /etc/supervisor/conf.d/nginx.conf +COPY cron.conf /etc/supervisor/conf.d/cron.conf +COPY streamrecord.conf /etc/supervisor/conf.d/streamrecord.conf +COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf + +# Install python app code +COPY streamrecord/ /home/streamrecord/app/ +RUN chown -R streamrecord /home/streamrecord/app ; \ + su -c "mkdir /home/streamrecord/app/files /home/streamrecord/app/files/output /home/streamrecord/app/temp /home/streamrecord/app/sessions" streamrecord ; \ + rm -rf /etc/cron* + +EXPOSE 80 + diff --git a/cron.conf b/cron.conf new file mode 100644 index 0000000..75c0110 --- /dev/null +++ b/cron.conf @@ -0,0 +1,3 @@ +[program:cron] +command=/usr/sbin/cron -f +autorestart=true diff --git a/default b/default new file mode 100644 index 0000000..85a22dd --- /dev/null +++ b/default @@ -0,0 +1,16 @@ +server { + listen 80; + #listen [::]:80 ipv6only=on; + root /usr/share/nginx/html/; + include uwsgi_params; + + access_log /var/log/nginx/stremrecord.log; + + location / { + uwsgi_pass 127.0.0.1:3330; + } + location /static/ { + autoindex on; + alias /home/streamrecord/app/static/; + } +} diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f23de88 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,3 @@ +[program:nginx] +command=/usr/sbin/nginx +autorestart=true diff --git a/streamrecord.conf b/streamrecord.conf new file mode 100644 index 0000000..42534e9 --- /dev/null +++ b/streamrecord.conf @@ -0,0 +1,4 @@ +[program:streamrecord] +command=/usr/bin/uwsgi --ini /etc/uwsgi/apps-enabled/streamrecord.ini --uid streamrecord --gid streamrecord +autorestart=true + diff --git a/streamrecord.ini b/streamrecord.ini new file mode 100644 index 0000000..d897074 --- /dev/null +++ b/streamrecord.ini @@ -0,0 +1,18 @@ +[uwsgi] +no-orphans = true +log-date = true +uid = streamrecord +pid = streamrecord +plugins = python3 +touch-reload = /home/streamrecord/app/app.py +chdir = /home/streamrecord/app/ +wsgi-file = /home/streamrecord/app/app.py +callable = application +master = true +processes = 1 +socket = 127.0.0.1:3330 +;pidfile = /tmp/streamrecord.pid +enable-threads = true +no-threads-wait = true +die-on-term = true + diff --git a/supervisor.conf b/supervisor.conf new file mode 100644 index 0000000..3fb016d --- /dev/null +++ b/supervisor.conf @@ -0,0 +1,3 @@ +[supervisord] +nodaemon=true +