Created
September 9, 2020 13:08
-
-
Save asizikov/7dd30258087911963f9a3b7ff58d8344 to your computer and use it in GitHub Desktop.
node server
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
FROM node:12 AS appbuild | |
WORKDIR /usr/src/app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
EXPOSE 8080 | |
CMD [ "node", "server.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
{ | |
"name": "docker_web_app", | |
"version": "1.0.0", | |
"description": "Node.js on Docker", | |
"author": "First Last <first.last@example.com>", | |
"main": "server.js", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"dependencies": { | |
"express": "^4.16.1" | |
} | |
} |
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
'use strict'; | |
const express = require('express'); | |
// Constants | |
const PORT = 8080; | |
const HOST = '0.0.0.0'; | |
// App | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.send('Hello World'); | |
}); | |
app.post('/test', (req, res) => { | |
var seconds = 960; | |
var waitTill = new Date(new Date().getTime() + seconds * 1000); | |
while(waitTill > new Date()){} | |
res.send("Done"); | |
// 900000 | |
}); | |
app.listen(PORT, HOST); | |
console.log(`Running on http://${HOST}:${PORT}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment