Skip to content

Make configuration more flexible to simplify deployment in other containerized execution environments #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
FROM node:16
RUN apt-get update && apt-get install -y netcat

ENV MONGO_HOST=mongo\
MONGO_PORT=27017

# Define directory inside the container
WORKDIR /usr/src/app

# Copying the local directory to the container directory(/usr/src/app)
COPY . .

#Install app dependecies (wildcard ensures both package/package-lock.json are copied)
RUN npm install -g npm@9.6.2
RUN npm ci


RUN cd jiff && npm ci

EXPOSE 8080

CMD sh -c "while ! nc -z mongo 27017; do sleep 1; done && npm start"
CMD sh -c "while ! nc -z ${MONGO_HOST} ${MONGO_PORT}; do sleep 1; done && npm start"
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@ version: '3'
services:
web-mpc:
container_name: web-mpc
environment:
- MONGOHOST=mongodb://mongo:27017
restart: always
build: .
ports:
@@ -19,4 +17,4 @@ services:
ports:
- "27017:27017"
volumes:
- ./db:/data/db
- ./db:/data/db
11 changes: 7 additions & 4 deletions server/models/models.js
Original file line number Diff line number Diff line change
@@ -6,11 +6,14 @@

const mongoose = require('mongoose');

const mongohost = process.env.MONGOHOST|| 'mongodb://localhost:27017';
const mongo_host = process.env.MONGO_HOST || 'localhost';
const mongo_port = process.env.MONGO_PORT || '27017';

const mongo_connection_string = 'mongodb://'+ mongo_host + ':' + mongo_port;
(async function () {
try {
await mongoose.connect(mongohost+'/aggregate', { useMongoClient: true });
console.log('You are connected to ',mongohost);
await mongoose.connect(mongo_connection_string+'/aggregate', { useMongoClient: true });
console.log('You are connected to ',mongo_connection_string);
} catch (err) {
console.log('Could not connect to MongoDB server', err);
}
@@ -56,7 +59,7 @@ const SessionInfoModel = mongoose.model('SessionInfo', new mongoose.Schema({
{
usePushEach: true
}));

const UserKeyModel = mongoose.model('UserKey', new mongoose.Schema({
_id: String, // concat of session + userkey.
session: String,