diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile new file mode 100755 index 00000000..8d2e8d76 --- /dev/null +++ b/deploy/docker/Dockerfile @@ -0,0 +1,76 @@ +# +# Dockerfile to launch WebVirtMgr, see: +# https://github.com/retspen/webvirtmgr +# +# Build with: +# docker build --no-cache=true --rm=true -t webvirtmgr . +# +# Customize: +# * Replace 'authorized_keys' with your key(s) so you can login and inspect the container. +# +# Default credentials (in initial_data.json): L: admin P: admin +# + +FROM centos:6 + +ENV VERSION 0.1 + +MAINTAINER nuno.tavares@synrix.com + +RUN yum clean all && \ + yum -y update && \ + yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm && \ + yum -y install git python-pip libvirt-python libxml2-python python-websockify \ + supervisor nginx + +# +# For debugging +# +RUN yum clean all && \ + yum -y install telnet openssh-server sudo && \ + service sshd start && \ + service sshd stop && \ + yum clean all + +RUN mkdir /var/www && \ + cd /var/www && \ + git clone git://github.com/retspen/webvirtmgr.git webvirtmgr + +COPY initial_data.json /var/www/webvirtmgr + +RUN cd /var/www/webvirtmgr && \ + pip install -r requirements.txt && \ + cd /var/www/webvirtmgr && \ + ./manage.py syncdb --noinput && \ + ./manage.py loaddata ./initial_data.json && \ + ./manage.py collectstatic --noinput && \ + chown -R nginx:nginx /var/www/webvirtmgr + + + +# +# Installation instructions from: +# https://github.com/retspen/webvirtmgr/wiki/Setup-SSH-Authorization +# +RUN mkdir -p /var/lib/nginx/.ssh && \ + chmod 700 /var/lib/nginx/.ssh && \ + ssh-keygen -t rsa -C "webvirtmgr@portavita.nl" -P '' -f /var/lib/nginx/.ssh/id_rsa && \ + touch /var/lib/nginx/.ssh/config && \ + echo -e "StrictHostKeyChecking=no\nUserKnownHostsFile=/dev/null" >> /var/lib/nginx/.ssh/config && \ + mkdir -p /root/.ssh && \ + chmod 700 /root/.ssh && \ + chown nginx:nginx -R /var/lib/nginx && \ + sed -i 's,^user nginx;,user nginx;\ndaemon off;,' /etc/nginx/nginx.conf && \ + rm -f /etc/nginx/conf.d/default.conf + +COPY authorized_keys /root/.ssh/authorized_keys + +COPY nginx_conf.d_webvirtmgr.conf /etc/nginx/conf.d/webvirtmgr.conf + + + +COPY supervisor.d_webvirtmgr.ini /etc/supervisord.conf + +EXPOSE 22 80 + +ENTRYPOINT ["/usr/bin/supervisord"] diff --git a/deploy/docker/authorized_keys b/deploy/docker/authorized_keys new file mode 100644 index 00000000..33493aab --- /dev/null +++ b/deploy/docker/authorized_keys @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7rvoRSm8Ec7XSc4vg5om03DkZl8E7wY4K1SfuD1pgWolXcTE3m1+ivhXg7VGSUJB1vYU9Im1XbGZIgLVsZBcfTFG6OCEZp0BgO6qROulXQ/c5ZPAl21+hl+VKKZvHEIsQf3M2woSXOsZOcsblAcR4PUZTwSqPcqgWUKfLAUEq3B8UNhp9xKRXaN+4/4xnCJplLqW5xqFSjH5U/t4v7KMNroUB/9t2BvMdNDOK8gFAm/7Ec1cXG5tVVQ7sa+CA8tWgsOI6v+kKC3OD8i+Dlrip+fzqcGWFogUukY9oUNqxDQ4PhvwOZNwdLX7RMaU7KvHNhU6sjiVREZEJ/teQxsivQ== n.tavares@portavita.eu diff --git a/deploy/docker/initial_data.json b/deploy/docker/initial_data.json new file mode 100644 index 00000000..d940fc71 --- /dev/null +++ b/deploy/docker/initial_data.json @@ -0,0 +1,263 @@ +[ +{ + "pk": 1, + "model": "auth.permission", + "fields": { + "codename": "add_permission", + "name": "Can add permission", + "content_type": 1 + } +}, +{ + "pk": 2, + "model": "auth.permission", + "fields": { + "codename": "change_permission", + "name": "Can change permission", + "content_type": 1 + } +}, +{ + "pk": 3, + "model": "auth.permission", + "fields": { + "codename": "delete_permission", + "name": "Can delete permission", + "content_type": 1 + } +}, +{ + "pk": 4, + "model": "auth.permission", + "fields": { + "codename": "add_group", + "name": "Can add group", + "content_type": 2 + } +}, +{ + "pk": 5, + "model": "auth.permission", + "fields": { + "codename": "change_group", + "name": "Can change group", + "content_type": 2 + } +}, +{ + "pk": 6, + "model": "auth.permission", + "fields": { + "codename": "delete_group", + "name": "Can delete group", + "content_type": 2 + } +}, +{ + "pk": 7, + "model": "auth.permission", + "fields": { + "codename": "add_user", + "name": "Can add user", + "content_type": 3 + } +}, +{ + "pk": 8, + "model": "auth.permission", + "fields": { + "codename": "change_user", + "name": "Can change user", + "content_type": 3 + } +}, +{ + "pk": 9, + "model": "auth.permission", + "fields": { + "codename": "delete_user", + "name": "Can delete user", + "content_type": 3 + } +}, +{ + "pk": 10, + "model": "auth.permission", + "fields": { + "codename": "add_contenttype", + "name": "Can add content type", + "content_type": 4 + } +}, +{ + "pk": 11, + "model": "auth.permission", + "fields": { + "codename": "change_contenttype", + "name": "Can change content type", + "content_type": 4 + } +}, +{ + "pk": 12, + "model": "auth.permission", + "fields": { + "codename": "delete_contenttype", + "name": "Can delete content type", + "content_type": 4 + } +}, +{ + "pk": 13, + "model": "auth.permission", + "fields": { + "codename": "add_session", + "name": "Can add session", + "content_type": 5 + } +}, +{ + "pk": 14, + "model": "auth.permission", + "fields": { + "codename": "change_session", + "name": "Can change session", + "content_type": 5 + } +}, +{ + "pk": 15, + "model": "auth.permission", + "fields": { + "codename": "delete_session", + "name": "Can delete session", + "content_type": 5 + } +}, +{ + "pk": 16, + "model": "auth.permission", + "fields": { + "codename": "add_site", + "name": "Can add site", + "content_type": 6 + } +}, +{ + "pk": 17, + "model": "auth.permission", + "fields": { + "codename": "change_site", + "name": "Can change site", + "content_type": 6 + } +}, +{ + "pk": 18, + "model": "auth.permission", + "fields": { + "codename": "delete_site", + "name": "Can delete site", + "content_type": 6 + } +}, +{ + "pk": 19, + "model": "auth.permission", + "fields": { + "codename": "add_compute", + "name": "Can add compute", + "content_type": 7 + } +}, +{ + "pk": 20, + "model": "auth.permission", + "fields": { + "codename": "change_compute", + "name": "Can change compute", + "content_type": 7 + } +}, +{ + "pk": 21, + "model": "auth.permission", + "fields": { + "codename": "delete_compute", + "name": "Can delete compute", + "content_type": 7 + } +}, +{ + "pk": 22, + "model": "auth.permission", + "fields": { + "codename": "add_instance", + "name": "Can add instance", + "content_type": 8 + } +}, +{ + "pk": 23, + "model": "auth.permission", + "fields": { + "codename": "change_instance", + "name": "Can change instance", + "content_type": 8 + } +}, +{ + "pk": 24, + "model": "auth.permission", + "fields": { + "codename": "delete_instance", + "name": "Can delete instance", + "content_type": 8 + } +}, +{ + "pk": 25, + "model": "auth.permission", + "fields": { + "codename": "add_flavor", + "name": "Can add flavor", + "content_type": 9 + } +}, +{ + "pk": 26, + "model": "auth.permission", + "fields": { + "codename": "change_flavor", + "name": "Can change flavor", + "content_type": 9 + } +}, +{ + "pk": 27, + "model": "auth.permission", + "fields": { + "codename": "delete_flavor", + "name": "Can delete flavor", + "content_type": 9 + } +}, +{ + "pk": 1, + "model": "auth.user", + "fields": { + "username": "admin", + "first_name": "", + "last_name": "", + "is_active": true, + "is_superuser": true, + "is_staff": true, + "last_login": "2016-11-21T20:30:58.604Z", + "groups": [], + "user_permissions": [], + "password": "pbkdf2_sha256$10000$oYZbF7Gvt8dZ$DEHkJPeBIyPgTUp5jG+NInOhc2pLTiMkZwxrh7uQh7c=", + "email": "", + "date_joined": "2016-11-21T20:30:58.604Z" + } +} +] diff --git a/deploy/docker/nginx_conf.d_webvirtmgr.conf b/deploy/docker/nginx_conf.d_webvirtmgr.conf new file mode 100644 index 00000000..75b3eb9b --- /dev/null +++ b/deploy/docker/nginx_conf.d_webvirtmgr.conf @@ -0,0 +1,24 @@ + +server { + listen 80 default_server; + + server_name $hostname; + #access_log /var/log/nginx/webvirtmgr_access_log; + + location /static/ { + root /var/www/webvirtmgr/webvirtmgr; + expires max; + } + + location / { + proxy_pass http://127.0.0.1:8000; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for; + proxy_set_header Host $host:$server_port; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_connect_timeout 600; + proxy_read_timeout 600; + proxy_send_timeout 600; + client_max_body_size 1024M; # Set higher depending on your needs + } +} diff --git a/deploy/docker/supervisor.d_webvirtmgr.ini b/deploy/docker/supervisor.d_webvirtmgr.ini new file mode 100644 index 00000000..e0561a20 --- /dev/null +++ b/deploy/docker/supervisor.d_webvirtmgr.ini @@ -0,0 +1,48 @@ +[supervisord] +http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server) +logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) +logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) +logfile_backups=10 ; (num of main logfile rotation backups;default 10) +loglevel=info ; (logging level;default info; others: debug,warn) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +nodaemon=true ; (start in foreground if true;default false) +minfds=1024 ; (min. avail startup file descriptors;default 1024) +minprocs=200 ; (min. avail process descriptors;default 200) + +[supervisorctl] +serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL for a unix socket + +[program:sshd] +command=/usr/sbin/sshd -D +autostart=true +autorestart=true +logfile=/var/log/supervisor/sshd.log +log_stderr=true + +[program:nginx] +command=/usr/sbin/nginx -c /etc/nginx/nginx.conf +autostart=true +autorestart=true +logfile=/var/log/supervisor/nginx.log +log_stderr=true + +[program:webvirtmgr] +command=/usr/bin/python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py +directory=/var/www/webvirtmgr +autostart=true +autorestart=true +logfile=/var/log/supervisor/webvirtmgr.log +log_stderr=true +user=root +user=nginx + +[program:webvirtmgr-console] +command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console +directory=/var/www/webvirtmgr +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/webvirtmgr-console.log +redirect_stderr=true +user=root +user=nginx +