Created
May 22, 2019 06:43
-
-
Save chathuranga94/f7d0f526c43a72cefb23a4c4a76fc887 to your computer and use it in GitHub Desktop.
node-api
This file contains hidden or 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:8 | |
# Create app directory | |
WORKDIR /usr/src/app | |
# Install app dependencies | |
# A wildcard is used to ensure both package.json AND package-lock.json are copied | |
# where available (npm@5+) | |
COPY package*.json ./ | |
RUN npm install | |
# If you are building your code for production | |
# RUN npm ci --only=production | |
# Bundle app source | |
COPY . . | |
EXPOSE 8080 | |
CMD [ "npm", "start" ] |
This file contains hidden or 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 <[email protected]>", | |
"main": "server.js", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"dependencies": { | |
"express": "^4.16.1" | |
} | |
} |
This file contains hidden or 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\n'); | |
}); | |
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