Skip to content

Commit

Permalink
chore(docker): dockerized node app
Browse files Browse the repository at this point in the history
  • Loading branch information
Waasi committed Dec 1, 2018
1 parent 9fdc8e6 commit 8136b3e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM mhart/alpine-node

WORKDIR /app

COPY package.json .
COPY package-lock.json .
RUN npm install

COPY . .
EXPOSE 3000

CMD ["npm", "start"]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build:
docker-compose build

up:
docker-compose up
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const port = 3000
const MongoClient = require('mongodb').MongoClient;

// Connection URL
const url = 'mongodb://localhost:27017';
const url = process.env.MONGO_HOSTNAME;
// Database Name
const dbName = 'gotenacious';
app.use(express.json());
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3'
services:
dashboard:
build: .
depends_on:
- mongo
volumes:
- /node_modules
env_file:
- .env
ports:
- 3000:3000
mongo:
image: mongo
ports:
- 27017:27017
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon server.js"
"start": "nodemon server.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 8136b3e

Please sign in to comment.