From 021427431ac79df798fd5d6de3e6327b148c3194 Mon Sep 17 00:00:00 2001 From: Drasko DRASKOVIC Date: Wed, 20 Apr 2016 00:20:57 +0200 Subject: [PATCH] Correct Docker files Signed-off-by: Drasko DRASKOVIC --- Dockerfile | 6 +++--- docker-compose.yml | 51 +++++++++++++++++++++++++++++++++------------- server.js | 2 +- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1fe65834..9e694e0c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ MAINTAINER Mainflux RUN apt-get update -qq && apt-get install -y build-essential -RUN mkdir /src +RUN mkdir /mainflux ### # Installations @@ -19,8 +19,8 @@ RUN npm install -g gulp RUN npm install -g nodemon # Finally, install all project Node modules -WORKDIR /src -ADD package.json /src/package.json +COPY . /mainflux +WORKDIR /mainflux RUN npm install EXPOSE 8080 diff --git a/docker-compose.yml b/docker-compose.yml index 10834fa0..511010ea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,39 @@ -api: - build: . - volumes: - - ".:/src" - ports: - - "8080:8080" - # set up links so that api knows about db, redis, etc... - links: - - mongodb - container_name: mainflux-api-docker +### +# Copyright (c) Mainflux +# +# Mainflux server is licensed under an Apache license, version 2.0 license. +# All rights not explicitly granted in the Apache license, version 2.0 are reserved. +# See the included LICENSE file for more details. +### -mongodb: - image: mongo +### +# MongoDB +### +mongo: + image: mongo:3.2 + container_name: mainflux-mongodb + command: --smallfiles --nojournal + +### +# NATS +### +nats: + image: apcera/gnatsd:latest + container_name: mainflux-nats ports: - - "27017:27017" - container_name: mainflux-mongo-docker + - "4222:4222" + - "8333:8333" + +### +# Mainflux +### +mainflux: + image: mainflux/mainflux-lite:latest + container_name: mainflux-api + volumes: + - ./config:/mainflux/config + links: + - mongo + - nats + ports: + - "8080:8080" diff --git a/server.js b/server.js index 1260d5a9..bf4bb01e 100644 --- a/server.js +++ b/server.js @@ -19,7 +19,7 @@ var mongoose = require('mongoose'); /** Check if we run with Docker compose */ var dockerMongo = process.env.MONGODB_NAME; var dbUrl = ''; -if (dockerMongo && dockerMongo == '/mainflux-api-docker/mongodb') { +if (dockerMongo && dockerMongo == '/mainflux-api/mongodb') { dbUrl = 'mongodb://' + process.env.MONGODB_PORT_27017_TCP_ADDR + ':' + process.env.MONGODB_PORT_27017_TCP_PORT + '/' + config.db.name; } else { dbUrl = 'mongodb://' + config.db.addr + ':' + config.db.port + '/' + config.db.name;