├── .gitignore ├── Dockerfile ├── LICENSE ├── Procfile ├── README.md ├── bower.json ├── index.coffee ├── index.css ├── index.html └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | bower_components/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM dockerfile/nodejs 2 | MAINTAINER Vangie Du from Coding IDE Team 3 | 4 | EXPOSE 5000 5 | 6 | ADD *.json index.* ./ 7 | 8 | RUN npm install && node_modules/.bin/bower install --allow-root 9 | 10 | CMD ["npm", "start"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Guillermo Rauch 4 | 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: coffee index.coffee -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Web Terminal 2 | 3 | A web-based terminal for docker container. 4 | 5 | ### Demo 6 | 7 | [http://docker-web-terminal.coding.io](http://docker-web-terminal.coding.io) 8 | 9 | ### Run outside of docker 10 | 11 | $ npm install && bower install && npm start 12 | 13 | ### Build image 14 | 15 | docker build -t "vangie/docker-web-terminal" --rm . 16 | 17 | ### Start container 18 | 19 | docker run -d -p 5000:5000 vangie/docker-web-terminal:latest 20 | 21 | ### Open in browser 22 | 23 | open http://`boot2docker ip`:5000 24 | 25 | ### Author 26 | 27 | Vangie Du from Coding IDE Team [http://codelife.me](http://codelife.me) 28 | 29 | ### License 30 | 31 | The MIT License (MIT) 32 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docker-web-terminal", 3 | "version": "1.0.0", 4 | "authors": [ 5 | "Vangie Du " 6 | ], 7 | "description": "A web-based terminal for docker container", 8 | "keywords": [ 9 | "web-terminal", 10 | "terminal" 11 | ], 12 | "license": "MIT", 13 | "homepage": "https://coding.net/u/duwan/p/docker-web-terminal", 14 | "private": true, 15 | "ignore": [ 16 | "**/.*", 17 | "node_modules", 18 | "bower_components", 19 | "test", 20 | "tests" 21 | ], 22 | "dependencies": { 23 | "jquery": "~2.1.3", 24 | "socket.io-client": "~1.3.5", 25 | "sh.js": "CodeboxIDE/sh.js#~1.1.1", 26 | "coffeescript": "~1.9.1" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /index.coffee: -------------------------------------------------------------------------------- 1 | [pty, sio, express, http] = (require lib for lib in ['pty.js', 'socket.io', 'express', 'http']) 2 | [host, port] = ["0.0.0.0", process.env.PORT or 5000] 3 | 4 | server = http.createServer(express().use(express.static(__dirname))) 5 | 6 | sio.listen(server).sockets.on('connection', (socket)-> 7 | term = pty.spawn 'bash', ['-l'], {cwd: process.env.HOME} 8 | .on 'data', (data)-> socket.emit('data', data) 9 | .on 'exit', -> socket.emit('exit', {}) 10 | 11 | socket.on 'data', (data)-> term.write data 12 | .on 'resize', (data)-> term.resize(data.cols, data.rows) 13 | .on 'disconnect', -> term.destroy() 14 | ) 15 | 16 | server.listen port, host, -> console.log('Server Listening on %s:%d', host, port) -------------------------------------------------------------------------------- /index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0px; 3 | } 4 | .terminal-container { 5 | position: relative; 6 | width: 100%; 7 | height: 100%; 8 | font-family: Menlo,Monaco,"DejaVu Sans Mono",Consolas,"Andale Mono",monospace; 9 | } 10 | .terminal-container div { 11 | margin: 0px; 12 | padding: 0px; 13 | user-select: initial; 14 | -webkit-user-select: initial; 15 | } 16 | .terminal-container .terminal { 17 | width: 100%; 18 | height: 100%; 19 | font-size: 13px; 20 | line-height: 15px; 21 | white-space: pre; 22 | } 23 | .terminal-container .terminal-row { 24 | white-space: pre; 25 | height: 15px; 26 | overflow: hidden; 27 | } 28 | .terminal-container .terminal-input { 29 | position: absolute; 30 | top: 0; 31 | left: -1000%; 32 | background: rgba(255,255,255,0.75); 33 | color: black; 34 | border: 0; 35 | outline: 0; 36 | width: 100%; 37 | } 38 | .terminal-container .terminal-screen-keys { 39 | position: absolute; 40 | top: 0; 41 | right: 0; 42 | } 43 | .terminal-container .terminal-screen-keys button { 44 | background: -webkit-linear-gradient(top, #eeeef0, #d3d3d9); 45 | border: 1px solid #58575e; 46 | box-shadow: 0 2px 2px rgba(0,0,0,0.25), inset 0 -2px 0 rgba(0,0,0,0.25), inset 0 1px 0 #fff; 47 | border: 1px solid #000; 48 | border-radius: 2px; 49 | padding: 8px; 50 | font-size: 14px; 51 | text-shadow: 0 1px 0 #fff; 52 | } 53 | .terminal-container .terminal-screen-keys button:focus, .terminal-container .terminal-screen-keys button.active { 54 | outline: 0px; 55 | background: -webkit-linear-gradient(top, #ccccd0, #a3a3a9); 56 | } 57 | .terminal-container .terminal-size-indicator { 58 | position: absolute; 59 | bottom: 0; 60 | left: 0; 61 | background-color: rgba(255,255,255,0.75); 62 | color: black; 63 | padding: 0 3px; 64 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Docker Web Terminal 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 29 | 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docker-web-terminal", 3 | "version": "1.0.0", 4 | "description": "A web-based terminal for docker container", 5 | "main": "index.coffee", 6 | "scripts": { 7 | "start": "coffee index.coffee", 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "postinstall": "bower install" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://coding.net/duwan/docker-web-terminal.git" 14 | }, 15 | "keywords": [ 16 | "docker", 17 | "terminal", 18 | "tty", 19 | "web-terminal" 20 | ], 21 | "author": "Vangie Du (http://codelife.me)", 22 | "license": "ISC", 23 | "dependencies": { 24 | "bower": "^1.3.12", 25 | "coffee-script": "^1.9.1", 26 | "express": "^4.12.2", 27 | "pty.js": "^0.2.7-1", 28 | "socket.io": "^1.3.5" 29 | } 30 | } 31 | --------------------------------------------------------------------------------