Skip to content
Snippets Groups Projects
Commit d79f1af1 authored by Markus Grigull's avatar Markus Grigull
Browse files

Add support for development and production environment

parent 6478dde8
No related branches found
No related tags found
No related merge requests found
......@@ -7,5 +7,5 @@ COPY . .
RUN npm install
# Run the app
EXPOSE 3000
EXPOSE 4000
CMD [ "npm", "start" ]
......@@ -20,12 +20,24 @@
******************************************************************************/
module.exports = {
databaseName: 'VILLAS',
databaseURL: 'mongodb://localhost:27017/',
port: 4000,
secret: 'longsecretislong',
admin: {
username: 'admin',
password: 'admin'
development: {
databaseName: 'VILLAS',
databaseURL: 'mongodb://localhost:27017/',
port: 4000,
secret: 'longsecretislong',
admin: {
username: 'admin',
password: 'admin'
}
},
production: {
databaseName: 'VILLAS',
databaseURL: 'mongodb://database:27017/',
port: 4000,
secret: 'longsecretislong',
admin: {
username: 'admin',
password: 'admin'
}
}
}
};
node:
image: villasweb-backend
ports:
- "3000:3000"
links:
- mongo
environment:
- NODE_ENV=development
version: "2"
mongo:
image: mongo
ports:
- "27017:27017"
services:
backend:
image: villasweb-backend
ports:
- "4000:4000"
links:
- database
environment:
- NODE_ENV=production
database:
image: mongo:latest
......@@ -27,8 +27,6 @@ var morgan = require('morgan');
var cors = require('cors');
// local include
var config = require('./config');
var users = require('./routes/users');
var projects = require('./routes/projects');
var visualizations = require('./routes/visualizations');
......@@ -44,6 +42,9 @@ var User = require('./models/user');
// create application
var app = express();
// load configuration
var config = require('./config')[app.get('env')];
// configure app
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
......@@ -74,6 +75,8 @@ app.use(function(req, res, next) {
});
// development error handler
console.log("Environment: " + app.get('env'));
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment