Skip to content

Instantly share code, notes, and snippets.

@asciimike
Created January 8, 2019 15:41
Show Gist options
  • Save asciimike/182899ce657f42a8862b0b4500a1b4cf to your computer and use it in GitHub Desktop.
Save asciimike/182899ce657f42a8862b0b4500a1b4cf to your computer and use it in GitHub Desktop.
CLI in a container
FROM node:8
WORKDIR /usr/src/app
COPY package*.json ./
ENV NODE_ENV=production
RUN npm install --production
COPY . .
CMD [ "npm", "start" ]
<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>
{
"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"
}
}
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