Merge pull request #38 from drasko/master

Correct Docker stuff
This commit is contained in:
Drasko DRASKOVIC 2015-12-07 00:34:35 +01:00
commit f88a913333
4 changed files with 17 additions and 7 deletions

View File

@ -3,7 +3,8 @@
###
# Set the base image to Node, onbuild variant: https://registry.hub.docker.com/_/node/
FROM node:0.10.38
FROM node:4.2.3
MAINTAINER Mainflux
RUN apt-get update -qq && apt-get install -y build-essential

View File

@ -5,13 +5,20 @@ var config = require('../config/config');
*/
var mongojs = require('mongojs');
/** Docker MongoDB url */
var docker_mongo_url = process.env.MAINFLUX_MONGODB_1_PORT_27017_TCP_ADDR
/** Connect to DB */
console.log("Connecting to DB");
var collections = ['devices'];
var db = mongojs(docker_mongo_url || config.db.path + ':' + config.db.port + '/' + config.db.name);
/** Check if we run with Docker compose */
var dockerMongo = process.env.MONGODB_NAME;
var dbUrl = '';
if (dockerMongo && dockerMongo == '/mainflux-api-docker/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;
}
var db = mongojs(dbUrl);
/**
* EXPORTS

View File

@ -1,7 +1,7 @@
{
"message" : "We are in development",
"db" : {
"path" : "mongodb://localhost",
"addr" : "localhost",
"port" : "27017",
"name" : "test"
},

View File

@ -7,8 +7,10 @@ api:
# set up links so that api knows about db, redis, etc...
links:
- mongodb
container_name: mainflux-api-docker
mongodb:
image: mongo
ports:
- "27017:27017"
container_name: mainflux-mongo-docker