Skip to content
Snippets Groups Projects
Commit b28b1dd9 authored by Markus Klose's avatar Markus Klose
Browse files

Docker container mongoDb connection to server.

parent 552ae0a9
No related branches found
No related tags found
No related merge requests found
version: '3' version: '3'
services: services:
mongo: mongodb:
image: mongo image: mongo
ports: ports:
- 27017:27017 - 27017:27017
...@@ -14,6 +14,10 @@ services: ...@@ -14,6 +14,10 @@ services:
- 3000:3000 - 3000:3000
volumes: volumes:
- ./:/code - ./:/code
depends_on:
- mongodb
environment:
WAIT_HOSTS: mongodb:27017
volumes: volumes:
mongodb: mongodb:
...@@ -27,6 +27,21 @@ const { resolve } = require('path'); ...@@ -27,6 +27,21 @@ const { resolve } = require('path');
//DB Connection //DB Connection
mongoose.connect("mongodb://127.0.0.1:27017/cloudComputing"); mongoose.connect("mongodb://127.0.0.1:27017/cloudComputing");
/* const connectWithRetry = () => {
mongoose
.connect('mongodb://mongo:27017/cloudComputing', {useNewUrlParser: true})
.then(() => console.log("succesfully connected to DB"))
.catch((e) => {
console.log(e);
setTimeout(connectWithRetry, 5000);
});
};
connectWithRetry(); */
app.use(bodyParser.json()); app.use(bodyParser.json());
//Routes //Routes
app.use('/register', registerRoute); app.use('/register', registerRoute);
......
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