shows docker swarm stack

master
Marc Wäckerlin 6 years ago
parent 7096587f3a
commit 4d4f2e9a92
  1. 19
      Dockerfile
  2. 14
      app.js
  3. 20
      bin/www
  4. 2
      client/servicedock.js
  5. 24
      package.json
  6. 3
      start.sh
  7. 4
      style/style.styl
  8. 2
      views/index.pug
  9. 3
      views/layout.pug

@ -0,0 +1,19 @@
FROM mwaeckerlin/base
MAINTAINER mwaeckerlin
ENV PORT 4000
ENV CONTAINERNAME "servicedock"
RUN adduser -D npm
ADD --chown=npm . /app
WORKDIR /app
RUN apk add npm python docker make g++ \
&& npm install npm@latest -g \
&& rm -rf node_modules \
&& npm install \
&& npm audit fix --force \
&& apk del python make g++
#USER npm
EXPOSE $PORT
VOLUME /var/run/docker.sock

@ -4,19 +4,9 @@ var favicon = require('static-favicon')
var logger = require('morgan') var logger = require('morgan')
var cookieParser = require('cookie-parser') var cookieParser = require('cookie-parser')
var bodyParser = require('body-parser') var bodyParser = require('body-parser')
var io = require('socket.io').listen(app)
var docker = require('docker.js')(app, io)
io.sockets.on('connection', docker.connect(socket))
var routes = require('./routes/index') var routes = require('./routes/index')
var users = require('./routes/users')
var app = express() var app = express()
var io = require('socket.io').listen(app)
var docker = require('docker.js')(app, io)
io.sockets.on('connection', docker.connect(socket))
// view engine setup // view engine setup
app.set('views', path.join(__dirname, 'views')) app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'pug') app.set('view engine', 'pug')
@ -26,11 +16,12 @@ app.use(logger('dev'))
app.use(bodyParser.json()) app.use(bodyParser.json())
app.use(bodyParser.urlencoded()) app.use(bodyParser.urlencoded())
app.use(cookieParser()) app.use(cookieParser())
app.use(require('stylus').middleware(path.join(__dirname, 'public'))) app.use(require('stylus').middleware(path.join(__dirname, 'style')))
app.use(express.static(path.join(__dirname, 'style'))) app.use(express.static(path.join(__dirname, 'style')))
app.use(express.static(path.join(__dirname, 'client'))) app.use(express.static(path.join(__dirname, 'client')))
app.use(express.static(path.join(__dirname, 'node_modules', 'jquery', 'dist'))) app.use(express.static(path.join(__dirname, 'node_modules', 'jquery', 'dist')))
app.use(express.static(path.join(__dirname, 'node_modules', 'viz.js'))) app.use(express.static(path.join(__dirname, 'node_modules', 'viz.js')))
app.use(express.static(path.join(__dirname, 'node_modules', 'socket.io-client', 'dist')))
app.use(express.static(path.join(__dirname, 'node_modules', 'docker.js'))) app.use(express.static(path.join(__dirname, 'node_modules', 'docker.js')))
app.use('/', routes) app.use('/', routes)
@ -66,5 +57,4 @@ app.use(function(err, req, res, next) {
}) })
}) })
module.exports = app module.exports = app

@ -1,9 +1,17 @@
#!/usr/bin/nodejs #!/usr/bin/node
var debug = require('debug')('ServiceDock');
var app = require('../app');
app.set('port', process.env.PORT || 4000); var debug = require('debug')('ServiceDock')
var app = require('../app')
app.set('port', process.env.PORT || 4000)
var server = app.listen(app.get('port'), function() { var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port); debug('Express server listening on port ' + server.address().port)
}); })
var io = require('socket.io').listen(server)
var docker = require('docker.js')(app, io)
io.sockets.on('connection', docker.connect)
debug('Socket server listening on port ' + server.address().port);

@ -5,6 +5,6 @@ function error(msg) {
} }
function init() { function init() {
socket = io.connect(); socket = io.connect();
docker = new Docker(socket, '#main', error); docker = new Docker(socket, error, '#containers', '#nodes', '#stacks');
} }
$(init); $(init);

@ -1,19 +1,21 @@
{ {
"name": "ServiceDock", "name": "ServiceDock",
"version": "2.0.0", "version": "2.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "nodejs ./bin/www" "start": "./bin/www"
}, },
"dependencies": { "dependencies": {
"body-parser": "~1.0.0", "body-parser": "*",
"cookie-parser": "~1.0.1", "cookie-parser": "*",
"debug": "~0.7.4", "debug": "*",
"docker.js": "^1.0.1", "docker.js": ">=1.2.0",
"express": "~4.0.0", "express": "*",
"morgan": "~1.0.0", "morgan": "*",
"pug": "^2.0.3", "pty.js": "*",
"static-favicon": "~1.0.0", "pug": "*",
"stylus": "0.42.3" "socket.io": "*",
"static-favicon": "*",
"stylus": "*"
} }
} }

@ -0,0 +1,3 @@
#!/bin/sh
npm start

@ -3,3 +3,7 @@ body
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif font: 14px "Lucida Grande", Helvetica, Arial, sans-serif
a a
color: #00B7FF color: #00B7FF
#main > svg
width: 100%
height: auto

@ -2,4 +2,4 @@ extends layout
block content block content
h1 ServiceDock h1 ServiceDock
div#main div#stacks

@ -2,10 +2,11 @@ doctype html
html html
head head
title= title title= title
link(rel='stylesheet', href='/stylesheets/style.css') link(rel='stylesheet', href='/style.css')
script(type="text/javascript", src="/jquery.min.js") script(type="text/javascript", src="/jquery.min.js")
script(type="text/javascript", src="/viz.js") script(type="text/javascript", src="/viz.js")
script(type="text/javascript", src="/docker.js") script(type="text/javascript", src="/docker.js")
script(type="text/javascript", src="/socket.io.js")
script(type="text/javascript", src="/servicedock.js") script(type="text/javascript", src="/servicedock.js")
body body
block content block content
Loading…
Cancel
Save