Skip to content

Commit

Permalink
first commit, a first app with docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Const committed Aug 12, 2017
0 parents commit e9b87c9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.idea
.vs
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:8-alpine

WORKDIR /usr/app

ADD . /usr/app
RUN npm install --quiet

EXPOSE 8080

CMD ["npm", "start"]
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "docker-node-application",
"version": "1.0.0",
"scripts": {
"start": "node server/server.js"
},
"dependencies": {
"express": "^4.15.2"
}
}

17 changes: 17 additions & 0 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const express = require('express');

// Constants
const PORT = 8080;
const HOST = '0.0.0.0';

// App
const app = express();
const host = process.env.HOSTNAME || '0.0.0.0';
app.get('/', (req, res) => {
res.send(`<h1>Hello world!!</h1><p>${host}</p>`);
});

app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);

0 comments on commit e9b87c9

Please sign in to comment.