Parcourir la source

Add of mongo DB docker instance

Jérôme BUISINE il y a 5 ans
Parent
commit
1b7414db58
3 fichiers modifiés avec 36 ajouts et 15 suppressions
  1. 2 1
      .gitignore
  2. 33 13
      docker-compose.yml
  3. 1 1
      server/webSocket/index.js

+ 2 - 1
.gitignore

@@ -23,4 +23,5 @@ yarn-error.log*
 /images
 /dist
 /logs
-/test/images
+/test/images
+/data/*

+ 33 - 13
docker-compose.yml

@@ -2,17 +2,37 @@ version: '3'
 
 services:
 
-  backapp:
-      build:
-          context: .
-          dockerfile: back.Dockerfile
-      image: backapp
-      ports:
+    # Documentation : https://docs.docker.com/samples/library/mongo/ 
+    mongo:
+        image: mongo
+        restart: always
+        environment:
+            MONGO_INITDB_ROOT_USERNAME: common 
+            MONGO_INITDB_ROOT_PASSWORD: webexpe
+
+            # TODO : Remove later if unecessary
+            # MONGO_INITDB_DATABASE: webexpe
+            # DATADIR: "${DATADIR:-data}"
+        volumes:
+            - "./data:/data/db" # get access to database files
+        ports:
+           - "27017:27017"
+ 
+    backapp:
+        build:
+            context: .
+            dockerfile: back.Dockerfile
+        image: backapp
+        ports:
           - "${PORT:-5000}:5000"
-      environment:
-          NODE_ENV: production
-          SERVE_CLIENT: "${SERVE_CLIENT:-true}"
-          PORT: "5000"
-      volumes:
-          - "${IMAGES_PATH:-./images}:/usr/src/app/images"
-          - "./logs:/usr/src/app/logs"
+        environment:
+            NODE_ENV: production
+            SERVE_CLIENT: "${SERVE_CLIENT:-true}"
+            PORT: "5000"
+        volumes:
+            - "${IMAGES_PATH:-./images}:/usr/src/app/images"
+            - "./logs:/usr/src/app/logs"
+        depends_on:
+            - mongo 
+
+      

+ 1 - 1
server/webSocket/index.js

@@ -58,5 +58,5 @@ const createWsServer = httpServer => {
     ws.on('close', () => wsLogger.info(formatLog('Client disconnected.')))
   })
 }
-errorHandler()()
+
 export default createWsServer