Compare commits

..

17 Commits
1.0.2 ... 1.0.4

Author SHA1 Message Date
Anthony Lapenna
9e4f8c9fee Merge branch 'release/1.0.4' 2016-06-24 10:24:38 +12:00
Anthony Lapenna
ce2e6f80fc chore(version): bump version number 2016-06-24 10:24:27 +12:00
Anthony Lapenna
bf4622e4f5 refactor(ui): remove useless logging 2016-06-24 10:23:12 +12:00
Anthony Lapenna
9655f57698 docs(global): review documentation 2016-06-24 10:22:04 +12:00
Anthony Lapenna
808694d6b5 feat(global): hide containers with labels using -l flag (#19) 2016-06-24 10:11:49 +12:00
Anthony Lapenna
cd12243b0f feat(ui): latest Swarm API support (#18)
* feat(ui): latest Swarm API support
2016-06-24 10:11:25 +12:00
Anthony Lapenna
abfa921b7a feat(ui): new logo size 2016-06-23 17:36:01 +12:00
Anthony Lapenna
91f3b1f138 refactor(service): Config factory returns a promise 2016-06-21 18:35:21 +12:00
Anthony Lapenna
9468839bf9 chore(grunt): run-swarm task expect a Swarm cluster at 10.0.7.10:4000 2016-06-21 18:34:32 +12:00
Anthony Lapenna
9ca2aa9bbd refactor(dockerui): replace -s flag with -swarm 2016-06-21 12:27:32 +12:00
Anthony Lapenna
54c82a3a5c add section in README about Swarm support 2016-06-16 17:39:59 +12:00
Anthony Lapenna
9360693f8d clean:all on release grunt task 2016-06-16 17:37:57 +12:00
Anthony Lapenna
c54dd510ad Merge tag '1.0.3' into develop
Release 1.0.3
2016-06-16 17:29:30 +12:00
Anthony Lapenna
b940c7bfbd Merge branch 'release/1.0.3' 2016-06-16 17:29:25 +12:00
Anthony Lapenna
1460d69cd1 bump version number 2016-06-16 17:29:12 +12:00
Anthony Lapenna
a7619b06ba configuration is now exposed in /config endpoint (#13) 2016-06-16 17:27:07 +12:00
Anthony Lapenna
f3a5251fd4 Merge tag '1.0.2' into develop
Release 1.0.2
2016-06-14 14:36:31 +12:00
15 changed files with 349 additions and 37 deletions

View File

@@ -1,4 +1,4 @@
## Cloudinovasi UI for Docker
# Cloudinovasi UI for Docker
A fork of the amazing UI for Docker by Michael Crosby and Kevan Ahlquist (https://github.com/kevana/ui-for-docker) using the rdash-angular theme (https://github.com/rdash/rdash-angular).
@@ -6,11 +6,14 @@ A fork of the amazing UI for Docker by Michael Crosby and Kevan Ahlquist (https:
UI For Docker is a web interface for the Docker Remote API. The goal is to provide a pure client side implementation so it is effortless to connect and manage docker.
### Goals
## Goals
* Minimal dependencies - I really want to keep this project a pure html/js app.
* Consistency - The web UI should be consistent with the commands found on the docker CLI.
## Run
### Quickstart
1. Run: `docker run -d -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock cloudinovasi/cloudinovasi-ui`
2. Open your browser to `http://<dockerd host ip>:9000`
@@ -25,11 +28,54 @@ By default UI For Docker connects to the Docker daemon with`/var/run/docker.sock
You can use the `-e` flag to change this socket:
# Connect to a tcp socket:
$ docker run -d -p 9000:9000 --privileged cloudinovasi/cloudinovasi-ui -e http://127.0.0.1:2375
```
# Connect to a tcp socket:
$ docker run -d -p 9000:9000 cloudinovasi/cloudinovasi-ui -e http://127.0.0.1:2375
```
### Swarm support
**Supported Swarm version: 1.2.3**
You can access a specific view for you Swarm cluster by defining the `-swarm` flag:
```
# Connect to a tcp socket and enable Swarm:
$ docker run -d -p 9000:9000 cloudinovasi/cloudinovasi-ui -e http://<SWARM_HOST>:<SWARM_PORT> -swarm
```
*NOTE*: Due to Swarm not exposing information in a machine readable way, the app is bound to a specific version of Swarm at the moment.
### Change address/port UI For Docker is served on
UI For Docker listens on port 9000 by default. If you run UI For Docker inside a container then you can bind the container's internal port to any external address and port:
# Expose UI For Docker on 10.20.30.1:80
$ docker run -d -p 10.20.30.1:80:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock cloudinovasi/cloudinovasi-ui
```
# Expose UI For Docker on 10.20.30.1:80
$ docker run -d -p 10.20.30.1:80:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock cloudinovasi/cloudinovasi-ui
```
### Hide containers with specific labels
You can hide specific containers in the containers view by using the `-hide-label` or `-l` options and specifying a label.
For example, take a container started with the label `owner=acme`:
```
$ docker run -d --label owner=acme nginx
```
You can hide it in the view by starting the ui with:
```
$ docker run -d -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock cloudinovasi/cloudinovasi-ui -l owner=acme
```
### Available options
The following options are available for the `ui-for-docker` binary:
* `-endpoint`, `-e`: Docker deamon endpoint (default: *"/var/run/docker.sock"*)
* `-bind`, `-p`: Address and port to serve UI For Docker (default: *":9000"*)
* `-assets`, `-a`: Path to the assets (default: *"."*)
* `-swarm`, `-s`: Swarm cluster support (default: *false*)
* `-hide-label`, `-l`: Hide containers with a specific label in the UI

View File

@@ -10,6 +10,7 @@ angular.module('uifordocker', [
'dashboard',
'container',
'containers',
'docker',
'images',
'image',
'pullImage',
@@ -56,6 +57,11 @@ angular.module('uifordocker', [
templateUrl: 'app/components/containerLogs/containerlogs.html',
controller: 'ContainerLogsController'
})
.state('docker', {
url: '/docker/',
templateUrl: 'app/components/docker/docker.html',
controller: 'DockerController'
})
.state('images', {
url: '/images/',
templateUrl: 'app/components/images/images.html',
@@ -113,4 +119,5 @@ angular.module('uifordocker', [
// You need to set this to the api endpoint without the port i.e. http://192.168.1.9
.constant('DOCKER_ENDPOINT', 'dockerapi')
.constant('DOCKER_PORT', '') // Docker port, leave as an empty string if no port is requred. If you have a port, prefix it with a ':' i.e. :4243
.constant('UI_VERSION', 'v1.0.2');
.constant('CONFIG_ENDPOINT', '/config')
.constant('UI_VERSION', 'v1.0.4');

View File

@@ -1,6 +1,6 @@
angular.module('containers', [])
.controller('ContainersController', ['$scope', 'Container', 'Settings', 'Messages', 'ViewSpinner',
function ($scope, Container, Settings, Messages, ViewSpinner) {
.controller('ContainersController', ['$scope', 'Container', 'Settings', 'Messages', 'ViewSpinner', 'Config',
function ($scope, Container, Settings, Messages, ViewSpinner, Config) {
$scope.state = {};
$scope.state.displayAll = Settings.displayAll;
@@ -18,9 +18,11 @@ function ($scope, Container, Settings, Messages, ViewSpinner) {
ViewSpinner.spin();
$scope.state.selectedItemCount = 0;
Container.query(data, function (d) {
$scope.containers = d.filter(function (container) {
return container.Image !== 'swarm';
}).map(function (container) {
var containers = d;
if (hiddenLabels) {
containers = hideContainers(d);
}
$scope.containers = containers.map(function (container) {
return new ContainerViewModel(container);
});
ViewSpinner.stop();
@@ -134,5 +136,24 @@ function ($scope, Container, Settings, Messages, ViewSpinner) {
batch($scope.containers, Container.remove, "Removed");
};
update({all: Settings.displayAll ? 1 : 0});
var hideContainers = function (containers) {
return containers.filter(function (container) {
var filterContainer = false;
hiddenLabels.forEach(function(label, index) {
if (_.has(container.Labels, label.name) &&
container.Labels[label.name] === label.value) {
filterContainer = true;
}
});
if (!filterContainer) {
return container;
}
});
};
var hiddenLabels;
Config.$promise.then(function (c) {
hiddenLabels = c.hiddenLabels;
update({all: Settings.displayAll ? 1 : 0});
});
}]);

View File

@@ -1,5 +1,5 @@
angular.module('dashboard')
.controller('MasterCtrl', ['$scope', '$cookieStore', 'Settings', function ($scope, $cookieStore, Settings) {
.controller('MasterCtrl', ['$scope', '$cookieStore', 'Settings', 'Config', function ($scope, $cookieStore, Settings, Config) {
/**
* Sidebar Toggle & Cookie Control
*/
@@ -9,6 +9,8 @@ angular.module('dashboard')
return window.innerWidth;
};
$scope.config = Config;
$scope.$watch($scope.getWidth, function(newValue, oldValue) {
if (newValue >= mobileView) {
if (angular.isDefined($cookieStore.get('toggle'))) {

View File

@@ -0,0 +1,145 @@
<rd-header>
<rd-header-title title="Engine overview">
<a data-toggle="tooltip" title="Refresh" ui-sref="docker" ui-sref-opts="{reload: true}">
<i class="fa fa-refresh" aria-hidden="true"></i>
</a>
</rd-header-title>
<rd-header-content>Docker</rd-header-content>
</rd-header>
<div class="row">
<div class="col-lg-3 col-md-6 col-xs-12">
<rd-widget>
<rd-widget-body>
<div class="widget-icon pull-left">
<i class="fa fa-code"></i>
</div>
<div class="title">{{ docker.Version }}</div>
<div class="comment">Docker version</div>
</rd-widget-body>
</rd-widget>
</div>
<div class="col-lg-3 col-md-6 col-xs-12">
<rd-widget>
<rd-widget-body>
<div class="widget-icon pull-left">
<i class="fa fa-code"></i>
</div>
<div class="title">{{ docker.ApiVersion }}</div>
<div class="comment">API version</div>
</rd-widget-body>
</rd-widget>
</div>
<div class="col-lg-3 col-md-6 col-xs-12">
<rd-widget>
<rd-widget-body>
<div class="widget-icon pull-left">
<i class="fa fa-code"></i>
</div>
<div class="title">{{ docker.GoVersion }}</div>
<div class="comment">Go version</div>
</rd-widget-body>
</rd-widget>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<rd-widget>
<rd-widget-header icon="fa-object-group" title="Cluster status"></rd-widget-header>
<rd-widget-body classes="no-padding">
<table class="table">
<tbody>
<tr>
<td>Containers</td>
<td>{{ info.Containers }}</td>
</tr>
<tr>
<td>Images</td>
<td>{{ info.Images }}</td>
</tr>
<tr>
<td>Debug</td>
<td>{{ info.Debug }}</td>
</tr>
<tr>
<td>CPUs</td>
<td>{{ info.NCPU }}</td>
</tr>
<tr>
<td>Total Memory</td>
<td>{{ info.MemTotal|humansize }}</td>
</tr>
<tr>
<td>Operating System</td>
<td>{{ info.OperatingSystem }}</td>
</tr>
<tr>
<td>Kernel Version</td>
<td>{{ info.KernelVersion }}</td>
</tr>
<tr>
<td>ID</td>
<td>{{ info.ID }}</td>
</tr>
<tr>
<td>Labels</td>
<td>{{ info.Labels }}</td>
</tr>
<tr>
<td>File Descriptors</td>
<td>{{ info.NFd }}</td>
</tr>
<tr>
<td>Goroutines</td>
<td>{{ info.NGoroutines }}</td>
</tr>
<tr>
<td>Storage Driver</td>
<td>{{ info.Driver }}</td>
</tr>
<tr>
<td>Storage Driver Status</td>
<td>
<p ng-repeat="val in info.DriverStatus">
{{ val[0] }}: {{ val[1] }}
</p>
</td>
</tr>
<tr>
<td>Execution Driver</td>
<td>{{ info.ExecutionDriver }}</td>
</tr>
<tr>
<td>IPv4 Forwarding</td>
<td>{{ info.IPv4Forwarding }}</td>
</tr>
<tr>
<td>Index Server Address</td>
<td>{{ info.IndexServerAddress }}</td>
</tr>
<tr>
<td>Init Path</td>
<td>{{ info.InitPath }}</td>
</tr>
<tr>
<td>Docker Root Directory</td>
<td>{{ info.DockerRootDir }}</td>
</tr>
<tr>
<td>Init SHA1</td>
<td>{{ info.InitSha1 }}</td>
</tr>
<tr>
<td>Memory Limit</td>
<td>{{ info.MemoryLimit }}</td>
</tr>
<tr>
<td>Swap Limit</td>
<td>{{ info.SwapLimit }}</td>
</tr>
</tbody>
</table>
</rd-widget-body>
</rd-widget>
</div>
</div>

View File

@@ -0,0 +1,19 @@
angular.module('docker', [])
.controller('DockerController', ['$scope', 'Info', 'Version', 'Settings',
function ($scope, Info, Version, Settings) {
$scope.info = {};
$scope.docker = {};
$scope.order = function(sortType) {
$scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
$scope.sortType = sortType;
};
Version.get({}, function (d) {
$scope.docker = d;
});
Info.get({}, function (d) {
$scope.info = d;
});
}]);

View File

@@ -115,6 +115,13 @@
<span ng-show="sortType == 'Containers' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
</a>
</th>
<th>
<a ui-sref="swarm" ng-click="order('Engine')">
Engine
<span ng-show="sortType == 'Engine' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span>
<span ng-show="sortType == 'Engine' && sortReverse" class="glyphicon glyphicon-chevron-up"></span>
</a>
</th>
<th>
<a ui-sref="swarm" ng-click="order('Status')">
Status
@@ -129,6 +136,7 @@
<td>{{ node.name }}</td>
<td>{{ node.ip }}</td>
<td>{{ node.containers }}</td>
<td>{{ node.version }}</td>
<td><span class="label label-{{ node.status|statusbadge }}">{{ node.status }}</span></td>
</tr>
</tbody>

View File

@@ -42,7 +42,7 @@ angular.module('swarm', [])
var node_offset = 4;
for (i = 0; i < node_count; i++) {
extractNodeInfo(info, node_offset);
node_offset += 9;
node_offset += 10;
}
}
@@ -50,7 +50,8 @@ angular.module('swarm', [])
var node = {};
node.name = info[offset][0];
node.ip = info[offset][1];
node.status = info[offset + 1][1];
node.id = info[offset + 1][1];
node.status = info[offset + 2][1];
node.containers = info[offset + 2][1];
node.cpu = info[offset + 3][1];
node.memory = info[offset + 4][1];

View File

@@ -142,6 +142,9 @@ angular.module('dockerui.services', ['ngResource', 'ngSanitize'])
remove: {method: 'DELETE'}
});
}])
.factory('Config', ['$resource', 'CONFIG_ENDPOINT', function($resource, CONFIG_ENDPOINT) {
return $resource(CONFIG_ENDPOINT).get();
}])
.factory('Settings', ['DOCKER_ENDPOINT', 'DOCKER_PORT', 'UI_VERSION', function SettingsFactory(DOCKER_ENDPOINT, DOCKER_PORT, UI_VERSION) {
'use strict';
var url = DOCKER_ENDPOINT;
@@ -150,11 +153,11 @@ angular.module('dockerui.services', ['ngResource', 'ngSanitize'])
}
var firstLoad = (localStorage.getItem('firstLoad') || 'true') === 'true';
return {
displayAll: false,
endpoint: DOCKER_ENDPOINT,
uiVersion: UI_VERSION,
url: url,
firstLoad: firstLoad
displayAll: false,
endpoint: DOCKER_ENDPOINT,
uiVersion: UI_VERSION,
url: url,
firstLoad: firstLoad
};
}])
.factory('ViewSpinner', function ViewSpinnerFactory() {

View File

@@ -116,8 +116,11 @@
.logo {
display: inline;
width: 110px;
max-height: 38px;
width: 100%;
max-width: 160px;
height: 100%;
max-height: 55px;
margin-bottom: 5px;
}
.containerNameInput {

View File

@@ -1,6 +1,6 @@
{
"name": "uifordocker",
"version": "1.0.2",
"version": "1.0.4",
"homepage": "https://github.com/kevana/ui-for-docker",
"authors": [
"Michael Crosby <crosbymichael@gmail.com>",

View File

@@ -1,25 +1,28 @@
package main // import "github.com/cloudinovasi/cloudinovasi-ui"
package main // import "github.com/cloudinovasi/ui-for-docker"
import (
"flag"
"io"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"encoding/json"
"os"
"strings"
"github.com/gorilla/csrf"
"io/ioutil"
"fmt"
"github.com/gorilla/securecookie"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
endpoint = flag.String("e", "/var/run/docker.sock", "Dockerd endpoint")
addr = flag.String("p", ":9000", "Address and port to serve UI For Docker")
assets = flag.String("a", ".", "Path to the assets")
endpoint = kingpin.Flag("endpoint", "Dockerd endpoint").Default("/var/run/docker.sock").Short('e').String()
addr = kingpin.Flag("bind", "Address and port to serve UI For Docker").Default(":9000").Short('p').String()
assets = kingpin.Flag("assets", "Path to the assets").Default(".").Short('a').String()
swarm = kingpin.Flag("swarm", "Swarm cluster support").Default("false").Short('s').Bool()
labels = LabelParser(kingpin.Flag("hide-label", "Hide containers with a specific label in the UI").Short('l'))
authKey []byte
authKeyFile = "authKey.dat"
)
@@ -28,6 +31,44 @@ type UnixHandler struct {
path string
}
type Config struct {
Swarm bool `json:"swarm"`
HiddenLabels Labels `json:"hiddenLabels"`
}
type Label struct {
Name string `json:"name"`
Value string `json:"value"`
}
type Labels []Label
func (l *Labels) Set(value string) error {
parts := strings.SplitN(value, "=", 2)
if len(parts) != 2 {
return fmt.Errorf("expected HEADER=VALUE got '%s'", value)
}
label := new(Label)
label.Name = parts[0]
label.Value = parts[1]
*l = append(*l, *label)
return nil
}
func (l *Labels) String() string {
return ""
}
func (l *Labels) IsCumulative() bool {
return true
}
func LabelParser(s kingpin.Settings) (target *[]Label) {
target = new([]Label)
s.SetValue((*Labels)(target))
return
}
func (h *UnixHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
conn, err := net.Dial("unix", h.path)
if err != nil {
@@ -60,6 +101,10 @@ func copyHeader(dst, src http.Header) {
}
}
func configurationHandler(w http.ResponseWriter, r *http.Request, c Config) {
json.NewEncoder(w).Encode(c)
}
func createTcpHandler(e string) http.Handler {
u, err := url.Parse(e)
if err != nil {
@@ -72,7 +117,7 @@ func createUnixHandler(e string) http.Handler {
return &UnixHandler{e}
}
func createHandler(dir string, e string) http.Handler {
func createHandler(dir string, e string, c Config) http.Handler {
var (
mux = http.NewServeMux()
fileHandler = http.FileServer(http.Dir(dir))
@@ -112,6 +157,9 @@ func createHandler(dir string, e string) http.Handler {
mux.Handle("/dockerapi/", http.StripPrefix("/dockerapi", h))
mux.Handle("/", fileHandler)
mux.HandleFunc("/config", func(w http.ResponseWriter, r *http.Request) {
configurationHandler(w, r, c)
})
return CSRF(csrfWrapper(mux))
}
@@ -123,9 +171,15 @@ func csrfWrapper(h http.Handler) http.Handler {
}
func main() {
flag.Parse()
kingpin.Version("1.0.4")
kingpin.Parse()
handler := createHandler(*assets, *endpoint)
configuration := Config{
Swarm: *swarm,
HiddenLabels: *labels,
}
handler := createHandler(*assets, *endpoint, configuration)
if err := http.ListenAndServe(*addr, handler); err != nil {
log.Fatal(err)
}

View File

@@ -24,7 +24,7 @@ module.exports = function (grunt) {
'copy'
]);
grunt.registerTask('release', [
'clean:app',
'clean:all',
'if:binaryNotExist',
'html2js',
'uglify',
@@ -37,7 +37,7 @@ module.exports = function (grunt) {
]);
grunt.registerTask('test-watch', ['karma:watch']);
grunt.registerTask('run', ['if:binaryNotExist', 'build', 'shell:buildImage', 'shell:run']);
grunt.registerTask('runSwarm', ['if:binaryNotExist', 'build', 'shell:buildImage', 'shell:runSwarm', 'watch:buildSwarm']);
grunt.registerTask('run-swarm', ['if:binaryNotExist', 'build', 'shell:buildImage', 'shell:runSwarm', 'watch:buildSwarm']);
grunt.registerTask('run-dev', ['if:binaryNotExist', 'shell:buildImage', 'shell:run', 'watch:build']);
grunt.registerTask('clear', ['clean:app']);
@@ -267,7 +267,7 @@ module.exports = function (grunt) {
command: [
'docker stop ui-for-docker',
'docker rm ui-for-docker',
'docker run --net=host -d --name ui-for-docker ui-for-docker -e http://10.0.7.11:4000'
'docker run --privileged -d -p 9000:9000 --name ui-for-docker ui-for-docker -e http://10.0.7.10:4000 -swarm'
].join(';')
},
cleanImages: {

View File

@@ -52,9 +52,12 @@
<li class="sidebar-list">
<a ui-sref="volumes">Volumes <span class="menu-icon fa fa-cubes"></span></a>
</li>
<li class="sidebar-list">
<li class="sidebar-list" ng-if="config.swarm">
<a ui-sref="swarm">Swarm <span class="menu-icon fa fa-object-group"></span></a>
</li>
<li class="sidebar-list" ng-if="!config.swarm">
<a ui-sref="docker">Docker <span class="menu-icon fa fa-cogs"></span></a>
</li>
</ul>
<div class="sidebar-footer">
<div class="col-xs-12">

View File

@@ -2,7 +2,7 @@
"author": "Michael Crosby & Kevan Ahlquist",
"name": "uifordocker",
"homepage": "https://github.com/kevana/ui-for-docker",
"version": "1.0.2",
"version": "1.0.4",
"repository": {
"type": "git",
"url": "git@github.com:kevana/ui-for-docker.git"