Added docker deployment, but the thing is broken, I guess a change in node js...

This commit is contained in:
Joe Tretter
2024-07-25 16:28:54 -05:00
parent dcbc6da170
commit 3b6fa6ecb3
3 changed files with 25 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules/
package-lock.json

15
Dockerfile Normal file
View 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"]

View File

@@ -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) {