Added docker deployment, but the thing is broken, I guess a change in node js...
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
package-lock.json
|
||||
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM alpine:latest
|
||||
RUN ["apk","update"]
|
||||
RUN ["apk","upgrade"]
|
||||
RUN ["apk","add", "--update","nodejs","npm"]
|
||||
RUN ["npm","install","-g", "forever"]
|
||||
RUN mkdir -p -m 0777 /docs
|
||||
COPY display.html /
|
||||
COPY EventSource.js /
|
||||
COPY package.json /
|
||||
COPY server.js /
|
||||
RUN ["npm","install"]
|
||||
RUN ["ln","-s", "node_modules/autosize/dist/autosize.min.js"]
|
||||
RUN echo "echo HALLO; cd /; node server.js" > /docker-entrypoint.sh; chmod 777 /docker-entrypoint.sh
|
||||
EXPOSE 8001
|
||||
CMD ["/bin/sh","-c","/docker-entrypoint.sh"]
|
||||
@@ -100,12 +100,17 @@ http.createServer(function(req, res) {
|
||||
console.log("Full path " + filePath + " [" + contentType + "]" );
|
||||
|
||||
try {
|
||||
console.log("A");
|
||||
var stat = fs.statSync(filePath);
|
||||
|
||||
console.log("B");
|
||||
var readStream = fs.createReadStream(filePath);
|
||||
console.log("C");
|
||||
res.writeHead(200, {"Content-Type":contentType});
|
||||
|
||||
console.log("D");
|
||||
readStream.pipe(res); // this will do a res.end() by its own.
|
||||
console.log("E");
|
||||
|
||||
} catch (ex) {
|
||||
res.writeHead(404,{"Content-Type":"text/html"});
|
||||
@@ -115,7 +120,9 @@ http.createServer(function(req, res) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}).listen(8001,'127.0.0.1');
|
||||
}).listen(8001,'0.0.0.0');
|
||||
console.log("server started.");
|
||||
console.log(__dirname);
|
||||
|
||||
// Send the server side event - consider that this response never ends, so no res.end() is called whatsowever!
|
||||
function sendSSE(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user