-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add node-example to investigate nodejs/node#8897
- Loading branch information
1 parent
b8f0985
commit a529f76
Showing
7 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
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
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"] |
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
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. |
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
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); | ||
}); |
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
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 |
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
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>“{{message}}”</body> | ||
</html> |
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
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" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
console.log('hello'); | ||
// console.log('current directory: ' + process.cwd()); |