Created
January 8, 2019 15:41
-
-
Save asciimike/182899ce657f42a8862b0b4500a1b4cf to your computer and use it in GitHub Desktop.
CLI in a container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:8 | |
WORKDIR /usr/src/app | |
COPY package*.json ./ | |
ENV NODE_ENV=production | |
RUN npm install --production | |
COPY . . | |
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="console"></div> | |
<script src="/console/console.js"></script> | |
<script> | |
const options = { | |
prefix: '/console', | |
env: { | |
CURRENT_FILE: getCurrentFile(), | |
CURRENT_APP: 'console-io' | |
} | |
}; | |
const konsole = Console('.console', options, function() { | |
console.log('console ready') | |
}); | |
konsole.focus(); | |
function getCurrentFile() { | |
return 'filename.txt'; | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "cli", | |
"version": "1.0.0", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"license": "Apache-2.0", | |
"dependencies": { | |
"console-io": "^7.0.6", | |
"express": "^4.16.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webconsole = require('console-io'); | |
const http = require('http'); | |
const express = require('express'); | |
const app = express(); | |
const server = http.createServer(app); | |
const port = 8080; | |
const ip = '0.0.0.0'; | |
const online = true; | |
app .use(webconsole({ | |
server, | |
online, /* load jquery and socket.io from cdn */ | |
})).use(express.static(__dirname)); | |
webconsole.listen({ | |
server | |
}); | |
server.listen(port, ip); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment