From eb3eb2d41fe679856c1c97335127bb2ead7ed438 Mon Sep 17 00:00:00 2001 From: oguzhanoya Date: Sun, 17 Sep 2017 03:00:27 +0300 Subject: [PATCH] Add build to docker support --- Dockerfile | 16 ++++++++++++++++ config/config.js | 2 +- docker-compose.yml | 16 ++++++++++++++++ pm2.json | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 pm2.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d1df3bf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Set the base image +FROM keymetrics/pm2:latest + +# Define working directory +WORKDIR / + +ADD . . + +# Install app dependencies +RUN npm install --production + +# Expose port +EXPOSE 3200 + +# Run app +CMD [ "pm2-docker", "start", "pm2.json" ] diff --git a/config/config.js b/config/config.js index 6d03a9b..0d78e13 100644 --- a/config/config.js +++ b/config/config.js @@ -27,7 +27,7 @@ const config = { hostname: process.env.HOSTNAME || 'localhost', }, database: { - url: 'mongodb://localhost/express-production', + url: 'mongodb://mongo:27017/express-production', }, }, }; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fa179a3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '2' +services: + mongo: + image: mongo:3.4 + ports: + - 27017:27017 + command: mongod --smallfiles --logpath=/dev/null # --quiet + web: + build: . + ports: + - "8080:3200" + links: + - mongo + depends_on: + - mongo + \ No newline at end of file diff --git a/pm2.json b/pm2.json new file mode 100644 index 0000000..e7fc9d1 --- /dev/null +++ b/pm2.json @@ -0,0 +1,11 @@ +{ + "apps": [ + { + "name": "express-mvc-boilerplate", + "script": "app.js", + "env": { + "NODE_ENV": "production" + } + } + ] +}