Skip to content

Commit

Permalink
Add node-example to investigate nodejs/node#8897
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanScherer committed Oct 3, 2016
1 parent b8f0985 commit a529f76
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 0 deletions.
7 changes: 7 additions & 0 deletions node-example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM stefanscherer/node-windows:6.7.0-nano

RUN npm install -g nodemon

WORKDIR /ContainerMappedDirectories

CMD ["nodemon.cmd", "--debug=5858", "app.js"]
25 changes: 25 additions & 0 deletions node-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# node-example

This is a test doing [Live Debugging With Docker](https://blog.docker.com/2016/07/live-debugging-docker/), but in Windows containers.
There is an issue running `node` or `npm` in a volume mount point in the container.
See https://github.com/nodejs/node/issues/8897 for details.

```
docker run -it -v c:\node-example:c:\code stefanscherer/node-windows:6.7.0-nano cmd
```

Now in the container

```
cd c:\code
npm install
```

or

```
cd c:\code
node test.js
```

Only workaround at the moment is to use `C:\ContainerMappedDirectories` as the mount point in the container.
33 changes: 33 additions & 0 deletions node-example/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var express = require('express');
var expressHandlebars = require('express-handlebars');
var http = require('http');

var PORT = 8000;

var LINES = [
"Hey, now, you're an All Star, get your game on, go play",
"Hey, now, you're a Rock Star, get the show on, get paid",
"And all that glitters is gold",
"Only shooting stars break the mold",
];

var lineIndex = 0;

var app = express();
app.engine('html', expressHandlebars());
app.set('view engine', 'html');
app.set('views', __dirname);
app.get('/', function(req, res) {
var message = LINES[lineIndex];

lineIndex += 1;
if (lineIndex > LINES.length) {
lineIndex = 0;
}

res.render('index', {message: message});
});

http.Server(app).listen(PORT, function() {
console.log("HTTP server listening on port %s", PORT);
});
16 changes: 16 additions & 0 deletions node-example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "2"

services:
web:
build: .
command: nodemon --debug=5858
volumes:
- .:c:\code
ports:
- "8000:8000"
- "5858:5858"

networks:
default:
external:
name: nat
19 changes: 19 additions & 0 deletions node-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html>
<head>
<meta http-equiv="refresh" content="2">

<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
font-weight: 600;
font-size: 56pt;
text-transform: uppercase;
text-align: center;
background: #3c3;
color: white;
}
</style>
</head>

<body>&ldquo;{{message}}&rdquo;</body>
</html>
7 changes: 7 additions & 0 deletions node-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"main": "app.js",
"dependencies": {
"express": "~4.14.0",
"express-handlebars": "~3.0.0"
}
}
2 changes: 2 additions & 0 deletions node-example/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
console.log('hello');
// console.log('current directory: ' + process.cwd());

0 comments on commit a529f76

Please sign in to comment.