-- Hello docker-compose
This commit is contained in:
parent
8979bb96db
commit
70805a0b2a
30
Dockerfile
30
Dockerfile
|
@ -2,34 +2,21 @@
|
||||||
# Mainflux Dockerfile
|
# Mainflux Dockerfile
|
||||||
###
|
###
|
||||||
# Set the base image to Node, onbuild variant: https://registry.hub.docker.com/_/node/
|
# Set the base image to Node, onbuild variant: https://registry.hub.docker.com/_/node/
|
||||||
FROM node:0.10-onbuild
|
|
||||||
|
|
||||||
# Maintained by Mainflux team
|
FROM node:0.10.38
|
||||||
MAINTAINER Mainflux <docker@mainflux.com>
|
|
||||||
|
|
||||||
# Log info
|
RUN apt-get update -qq && apt-get install -y build-essential
|
||||||
RUN echo "Starting Mainflux server..."
|
|
||||||
|
RUN mkdir /src
|
||||||
|
|
||||||
###
|
|
||||||
# Installations
|
|
||||||
###
|
|
||||||
# Add Gulp globally
|
|
||||||
RUN npm install -g gulp
|
RUN npm install -g gulp
|
||||||
|
RUN npm install -g nodemon
|
||||||
|
|
||||||
# Gulp also demands to be saved locally
|
WORKDIR /src
|
||||||
RUN npm install --save-dev gulp
|
ADD package.json /src/package.json
|
||||||
|
|
||||||
# Finally, install all project Node modules
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
###
|
EXPOSE 8080
|
||||||
# Setup the port
|
|
||||||
###
|
|
||||||
# Run Mainflux on port 80
|
|
||||||
ENV PORT 80
|
|
||||||
|
|
||||||
# Expose port on which we run Mainflux
|
|
||||||
EXPOSE $PORT
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Run main command from entrypoint and parameters in CMD[]
|
# Run main command from entrypoint and parameters in CMD[]
|
||||||
|
@ -39,4 +26,3 @@ CMD [""]
|
||||||
|
|
||||||
# Set default container command
|
# Set default container command
|
||||||
ENTRYPOINT gulp
|
ENTRYPOINT gulp
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* Following recipe here: http://dailyjs.com/2014/01/02/recipe-for-express-configuration/
|
* 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');
|
||||||
|
|
|
@ -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"
|
|
@ -18,7 +18,7 @@ gulp.task('jshint', function() {
|
||||||
// configure which files to watch and what tasks to use on file changes
|
// configure which files to watch and what tasks to use on file changes
|
||||||
gulp.task('watch', function() {
|
gulp.task('watch', function() {
|
||||||
gulp.watch('app/**/*.js', ['jshint']);
|
gulp.watch('app/**/*.js', ['jshint']);
|
||||||
|
|
||||||
// Start up the server and have it reload when anything in the
|
// Start up the server and have it reload when anything in the
|
||||||
// ./build/ directory changes
|
// ./build/ directory changes
|
||||||
nodemon({script: 'server.js', watch: 'app/**'});
|
nodemon({script: 'server.js', watch: 'app/**'});
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "node-api",
|
"name": "node-api",
|
||||||
|
"description": "Mainflux is an open source MIT licensed IoT cloud written in NodeJS",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Mainflux/mainflux"
|
||||||
|
},
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "~4.0.0",
|
"express": "~4.0.0",
|
||||||
"mongoose": "~3.6.13",
|
"mongoose": "~3.6.13",
|
||||||
|
|
|
@ -17,8 +17,10 @@ var bodyParser = require('body-parser');
|
||||||
|
|
||||||
// MongoDB
|
// MongoDB
|
||||||
var mongoose = require('mongoose');
|
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()
|
// configure app to use bodyParser()
|
||||||
|
|
Loading…
Reference in New Issue