create docker run commands from configuration json
This commit is contained in:
		
							
								
								
									
										15
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								ChangeLog
									
									
									
									
									
								
							@@ -1,3 +1,18 @@
 | 
			
		||||
2016-01-19 16:20  marc
 | 
			
		||||
 | 
			
		||||
	* nodejs/package.json.in, nodejs/public/javascripts/servicedock.js,
 | 
			
		||||
	  nodejs/public/stylesheets/servicedock.css,
 | 
			
		||||
	  nodejs/sockets/index.js, nodejs/views/index.ejs: new features log
 | 
			
		||||
	  and bash
 | 
			
		||||
 | 
			
		||||
2016-01-18 14:04  marc
 | 
			
		||||
 | 
			
		||||
	* ChangeLog, ax_init_standard_project.m4, bootstrap.sh,
 | 
			
		||||
	  build-in-docker.conf, build-in-docker.sh, configure.ac,
 | 
			
		||||
	  debian/control.in, doc/doxyfile.in, html, makefile.am,
 | 
			
		||||
	  nodejs/makefile.am, nodejs/package.json, nodejs/package.json.in,
 | 
			
		||||
	  resolve-debbuilddeps.sh: updated build from html/php to nodejs
 | 
			
		||||
 | 
			
		||||
2016-01-17 23:07  marc
 | 
			
		||||
 | 
			
		||||
	* ChangeLog, html/makefile.am, html/servicedock.js,
 | 
			
		||||
 
 | 
			
		||||
@@ -14,12 +14,24 @@ var focused = null;
 | 
			
		||||
function Docker() {
 | 
			
		||||
 | 
			
		||||
    function same(array1, array2) {
 | 
			
		||||
        if (!array1 && !array2) return true;
 | 
			
		||||
        if (!array1 || !array2) return false;
 | 
			
		||||
        return (array1.length == array2.length)
 | 
			
		||||
            && array1.every(function(element, index) {
 | 
			
		||||
                return element === array2[index]; 
 | 
			
		||||
            });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function quote(text) {
 | 
			
		||||
        if (text.match('"')) {
 | 
			
		||||
            if (!text.match("'")) return "'"+text+"'";
 | 
			
		||||
            else return '"'+text.replace(/"/g, '\\"')+'"';
 | 
			
		||||
        } else {
 | 
			
		||||
            if (text.match(' ')) return '"'+text+'"';
 | 
			
		||||
            else return text;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    var _docker = this;
 | 
			
		||||
 | 
			
		||||
    this.Images = function() {
 | 
			
		||||
@@ -56,9 +68,7 @@ function Docker() {
 | 
			
		||||
                if ((pos=instance.env.indexOf(e))>-1) instance.env.splice(pos, 1)
 | 
			
		||||
            })
 | 
			
		||||
            if (same(nodes[id].cmd, instance.cmd)) instance.cmd = null
 | 
			
		||||
            else console.log(instance.cmd+" != "+nodes[id].cmd)
 | 
			
		||||
            if (same(nodes[id].entrypoint, instance.entrypoint)) instance.entrypoint = null
 | 
			
		||||
            else console.log(instance.entrypoint+" != "+nodes[id].entrypoint)
 | 
			
		||||
        }
 | 
			
		||||
        this.set = function(c) {
 | 
			
		||||
            if (typeof c == "string") c = JSON.parse(c);
 | 
			
		||||
@@ -202,7 +212,7 @@ function Docker() {
 | 
			
		||||
        this.subgraph = function(name) {
 | 
			
		||||
            return this.graph(this.subnet(name));
 | 
			
		||||
        }
 | 
			
		||||
        this.creation = function(name) {
 | 
			
		||||
        this.configuration = function(name) {
 | 
			
		||||
            var ns = this.subnet(name);
 | 
			
		||||
            var creates = [];
 | 
			
		||||
            for (n in ns) {
 | 
			
		||||
@@ -227,14 +237,44 @@ function Docker() {
 | 
			
		||||
                creates.push(instance);
 | 
			
		||||
            }
 | 
			
		||||
            creates.sort(function(a, b) {
 | 
			
		||||
                if (a.volumesfrom.indexOf(b)>=0) return 1; // a after b
 | 
			
		||||
                if (b.volumesfrom.indexOf(a)>=0) return -1; // a before b
 | 
			
		||||
                if (a.volumesfrom.indexOf(b.name)>=0) return 1; // a after b
 | 
			
		||||
                if (b.volumesfrom.indexOf(a.name)>=0) return -1; // a before b
 | 
			
		||||
                for (var i=0; i<a.links.length; ++i) if (a.links[i].to == b.name) return 1; // a after b;
 | 
			
		||||
                for (var i=0; i<b.links.length; ++i) if (b.links[i].to == a.name) return -1; // a before b;
 | 
			
		||||
                if ((b.volumesfrom.length || b.links.length) && !(a.volumesfrom.length || a.links.length)) return 1; // a after b; 
 | 
			
		||||
                if ((a.volumesfrom.length || a.links.length) && !(b.volumesfrom.length || b.links.length)) return 1; // a after b; 
 | 
			
		||||
                return 0; // a and b do not depend on each other
 | 
			
		||||
            });
 | 
			
		||||
            return creates;
 | 
			
		||||
        }
 | 
			
		||||
        this.creation = function(name) {
 | 
			
		||||
            var res = [];
 | 
			
		||||
            this.configuration(name).forEach(function(n) {
 | 
			
		||||
                var cmd = "docker create -d --name "+quote(n.name);
 | 
			
		||||
                n.ports.forEach(function(p) {
 | 
			
		||||
                    cmd += " --publish "+(p.ip?quote(p.ip)+":":"")+p.external+":"+p.internal;
 | 
			
		||||
                });
 | 
			
		||||
                n.env.forEach(function(e) {
 | 
			
		||||
                    cmd += ' --env '+quote(e);
 | 
			
		||||
                });
 | 
			
		||||
                n.volumes.forEach(function(v) {
 | 
			
		||||
                    cmd += ' --volume '+quote(v.outside)+':'+quote(v.inside);
 | 
			
		||||
                });
 | 
			
		||||
                n.volumesfrom.forEach(function(v) {
 | 
			
		||||
                    cmd += ' --volumes-from '+quote(v);
 | 
			
		||||
                })
 | 
			
		||||
                n.links.forEach(function(l) {
 | 
			
		||||
                    cmd += ' --link '+quote(l.link)+':'+quote(l.to);
 | 
			
		||||
                });
 | 
			
		||||
                if (n.entrypoint && n.entrypoint.length) cmd += ' --entrypoint '+quote(n.entrypoint.join(" "));
 | 
			
		||||
                cmd += " "+n.image;
 | 
			
		||||
                if (n.cmd) n.cmd.forEach(function(c) {
 | 
			
		||||
                    cmd+= ' '+quote(c);
 | 
			
		||||
                });
 | 
			
		||||
                res.push(cmd);
 | 
			
		||||
            })
 | 
			
		||||
            return res;
 | 
			
		||||
        }
 | 
			
		||||
        function setup() {
 | 
			
		||||
            delete nodes; nodes = [];
 | 
			
		||||
            containers.forEach(function(c, i) {
 | 
			
		||||
@@ -740,7 +780,9 @@ function bash_data(data) {
 | 
			
		||||
    } else {
 | 
			
		||||
        $("#screen").append('<span class="'+data.type+'">'+ansifilter(htmlenc(data.text))+'</span>');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
    $("#screen").animate({
 | 
			
		||||
        scrollTop: $("#screen").scrollHeight()
 | 
			
		||||
    }, 500);}
 | 
			
		||||
 | 
			
		||||
function overview() {
 | 
			
		||||
    focused = null;
 | 
			
		||||
 
 | 
			
		||||
@@ -237,11 +237,11 @@ table.docker li+li {
 | 
			
		||||
  top: 1.5em;
 | 
			
		||||
  left: 0;
 | 
			
		||||
  right: 0;
 | 
			
		||||
  bottom: 1.5em;
 | 
			
		||||
  padding: 1em 1em 1em 1em;
 | 
			
		||||
  clear: both;
 | 
			
		||||
  overflow: auto;
 | 
			
		||||
  z-index: 0;
 | 
			
		||||
  bottom: 1.5em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#main {
 | 
			
		||||
@@ -332,7 +332,24 @@ table.docker li+li {
 | 
			
		||||
 | 
			
		||||
#console {
 | 
			
		||||
  background-color: black;
 | 
			
		||||
  color: white
 | 
			
		||||
  color: white;
 | 
			
		||||
  overflow: none;
 | 
			
		||||
}
 | 
			
		||||
#screen {
 | 
			
		||||
  position: fixed;
 | 
			
		||||
  top: 2em;
 | 
			
		||||
  bottom: 4em;
 | 
			
		||||
  left: 0;
 | 
			
		||||
  right: 0;
 | 
			
		||||
  overflow: auto;
 | 
			
		||||
  padding: 1ex;
 | 
			
		||||
}
 | 
			
		||||
#bash {
 | 
			
		||||
  position: fixed;
 | 
			
		||||
  bottom: 1.5em;
 | 
			
		||||
  left: 0;
 | 
			
		||||
  right: 0;
 | 
			
		||||
  padding: 0;
 | 
			
		||||
}
 | 
			
		||||
.bold {font-weight: bold}
 | 
			
		||||
.dim {color: grey}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user