Skip to content

Instantly share code, notes, and snippets.

@rahuls360
Created June 6, 2023 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahuls360/9a219bb7a59fa96a514fb1b620a4c069 to your computer and use it in GitHub Desktop.
Save rahuls360/9a219bb7a59fa96a514fb1b620a4c069 to your computer and use it in GitHub Desktop.
Basic nodejs server without any dependencies (on docker)
FROM node:18.12.1-alpine
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]
const http = require('http');
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, World!\n');
});
const port = 3000;
server.listen(port, () => {
console.log(`Server running on port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment