-- Hello docker-compose

This commit is contained in:
nmarcetic 2015-07-28 00:50:20 +02:00
parent 8979bb96db
commit 70805a0b2a
6 changed files with 33 additions and 25 deletions

View File

@ -2,34 +2,21 @@
# Mainflux Dockerfile
###
# Set the base image to Node, onbuild variant: https://registry.hub.docker.com/_/node/
FROM node:0.10-onbuild
# Maintained by Mainflux team
MAINTAINER Mainflux <docker@mainflux.com>
FROM node:0.10.38
# Log info
RUN echo "Starting Mainflux server..."
RUN apt-get update -qq && apt-get install -y build-essential
RUN mkdir /src
###
# Installations
###
# Add Gulp globally
RUN npm install -g gulp
RUN npm install -g nodemon
# Gulp also demands to be saved locally
RUN npm install --save-dev gulp
# Finally, install all project Node modules
WORKDIR /src
ADD package.json /src/package.json
RUN npm install
###
# Setup the port
###
# Run Mainflux on port 80
ENV PORT 80
# Expose port on which we run Mainflux
EXPOSE $PORT
EXPOSE 8080
###
# Run main command from entrypoint and parameters in CMD[]
@ -39,4 +26,3 @@ CMD [""]
# Set default container command
ENTRYPOINT gulp

View File

@ -1,4 +1,4 @@
/*
* Following recipe here: http://dailyjs.com/2014/01/02/recipe-for-express-configuration/
*/
module.exports = require('./' + (process.env.NODE_ENV || 'development') + '.json');
module.exports = require('./' + (process.env.NODE_ENV || 'development') + '.json');

14
docker-compose.yml Normal file
View File

@ -0,0 +1,14 @@
api:
build: .
volumes:
- ".:/src"
ports:
- "8080:8080"
# set up links so that api knows about db, redis, etc...
links:
- mongodb
mongodb:
image: mongo
ports:
- "27017:27017"

View File

@ -18,7 +18,7 @@ gulp.task('jshint', function() {
// configure which files to watch and what tasks to use on file changes
gulp.task('watch', function() {
gulp.watch('app/**/*.js', ['jshint']);
// Start up the server and have it reload when anything in the
// ./build/ directory changes
nodemon({script: 'server.js', watch: 'app/**'});

View File

@ -1,6 +1,12 @@
{
"name": "node-api",
"description": "Mainflux is an open source MIT licensed IoT cloud written in NodeJS",
"main": "server.js",
"repository": {
"type": "git",
"url": "https://github.com/Mainflux/mainflux"
},
"dependencies": {
"express": "~4.0.0",
"mongoose": "~3.6.13",

View File

@ -17,8 +17,10 @@ var bodyParser = require('body-parser');
// MongoDB
var mongoose = require('mongoose');
// Docker MongoDB url
var docker_mongo_url = process.env.MAINFLUX_MONGODB_1_PORT_27017_TCP_ADDR
mongoose.connect(config.db.path + ':' + config.db.port + '/' + config.db.name); // connect to our database
mongoose.connect(docker_mongo_url || config.db.path + ':' + config.db.port + '/' + config.db.name); // connect to our database
// configure app to use bodyParser()