From 157c0e13a77de82455cf5df11278ba05c7c1ad98 Mon Sep 17 00:00:00 2001 From: NyxiumYuuki Date: Fri, 28 May 2021 08:01:50 +0200 Subject: [PATCH] Docker added --- backend/service-authentication/Dockerfile | 4 +- .../service-authentication/mongodbConnect.js | 2 + docker-compose.yml | 101 +++++++----------- 3 files changed, 39 insertions(+), 68 deletions(-) diff --git a/backend/service-authentication/Dockerfile b/backend/service-authentication/Dockerfile index 77f61f6..b0b4790 100644 --- a/backend/service-authentication/Dockerfile +++ b/backend/service-authentication/Dockerfile @@ -1,8 +1,6 @@ -# syntax=docker/dockerfile:1 FROM node:current-slim -ENV NODE_ENV=production WORKDIR /app-authentication COPY ["package.json", "package-lock.json*", "./"] -RUN npm install --production +RUN npm install --NODE_ENV COPY . . CMD [ "node", "server.js" ] \ No newline at end of file diff --git a/backend/service-authentication/mongodbConnect.js b/backend/service-authentication/mongodbConnect.js index 004ee4e..dde6462 100644 --- a/backend/service-authentication/mongodbConnect.js +++ b/backend/service-authentication/mongodbConnect.js @@ -6,7 +6,9 @@ let db; module.exports = { connectToServer: function( callback ) { MongoClient.connect( uri, { useNewUrlParser: true, useUnifiedTopology: true }, function( err, client ) { + console.log(client.isConnected()); db = client.db(config.mongodbDatabase); + return callback( err ); }); }, diff --git a/docker-compose.yml b/docker-compose.yml index bb3d7fc..4912f89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,82 +1,53 @@ -version: '3.7' -networks: - net: +version: '3.8' services: - frontend: - image: frontend - environment: - SERVICE_ADRESS: frontend - SERVICE_PORT: 4200 - ports: - - 4200:4200 - networks: - - net - service-authentication: - image: service-authentication + build: backend/service-authentication + command: node server.js + volumes: + - backend/service-authentication + - backend/service-authentication/node_modules + ports: + - 3001:3000 + depends_on: + - mongodb-authentication environment: - SERVICE_ADRESS: service-authentication - SERVICE_PORT: 3000 - ports: - - 3000:3000 - networks: - - net + NODE_ENV: development service-message: - image: service-message + build: backend/service-message + command: node server.js + volumes: + - backend/service-message + - backend/service-message/node_modules + ports: + - 3000:3000 + depends_on: + - mongodb-message environment: - SERVICE_ADRESS: service-message - SERVICE_PORT: 3000 - ports: - - 3001:3000 - networks: - - net - service-notification: - image: service-notification - environment: - SERVICE_ADRESS: service-notification - SERVICE_PORT: 3000 - ports: - - 3002:3000 - networks: - - net - - service-privateroom: - image: service-privateroom - environment: - SERVICE_ADRESS: service-privateroom - SERVICE_PORT: 3000 - ports: - - 3003:3000 - networks: - - net + NODE_ENV: development mongodb-authentication: image: mongo - networks: - - net + container_name: mongodb-authentication + environment: + - PUID=1001 + - PGID=1001 + volumes: + - ./backend/service-authentication/database:/data/db ports: - - 27017:27017 + - 27017:27017 + restart: unless-stopped mongodb-message: image: mongo - networks: - - net + container_name: mongodb-message + environment: + - PUID=1000 + - PGID=1000 + volumes: + - ./backend/service-message/database:/data/db ports: - 27020:27017 - - mongodb-notification: - image: mongo - networks: - - net - ports: - - 27021:27017 - - mongodb-privateroom: - image: mongo - networks: - - net - ports: - - 27022:27017 \ No newline at end of file + restart: unless-stopped \ No newline at end of file