Skip to content

Commit 1cf0248

Browse files
committed
Move question DB to atlas
URI and password will be communicated privately :)
1 parent f906bf1 commit 1cf0248

File tree

5 files changed

+5
-26
lines changed

5 files changed

+5
-26
lines changed

.env.sample

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
# Copy this file to .env and replace the placeholder values with your own.
33

44
# Question Service
5-
QUESTION_DB_CLOUD_URI=<FILL-THIS-IN>
6-
QUESTION_DB_LOCAL_URI=mongodb://question-db:27017/question
5+
QUESTION_DB_URI=<fill-this-in>
76
QUESTION_DB_USERNAME=user
8-
QUESTION_DB_PASSWORD=password
7+
QUESTION_DB_PASSWORD=<fill-this-in>
98

109
# User Service
1110
USER_SERVICE_CLOUD_URI=mongodb+srv://admin:<db_password>@cluster0.uo0vu.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0

compose.dev.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ services:
1010
- /app/node_modules
1111
- ./services/question:/app
1212

13-
question-db:
14-
ports:
15-
- 27017:27017
16-
1713
user:
1814
command: npm run dev
1915
volumes:

compose.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,13 @@ services:
1818
ports:
1919
- 8081:8081
2020
environment:
21-
DB_CLOUD_URI: ${QUESTION_DB_CLOUD_URI}
22-
DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
21+
DB_URI: ${QUESTION_DB_URI}
2322
DB_USERNAME: ${QUESTION_DB_USERNAME}
2423
DB_PASSWORD: ${QUESTION_DB_PASSWORD}
2524
networks:
2625
- question-db-network
2726
restart: always
2827

29-
question-db:
30-
container_name: question-db
31-
image: mongo:7.0.14
32-
environment:
33-
MONGO_INITDB_ROOT_USERNAME: ${QUESTION_DB_USERNAME}
34-
MONGO_INITDB_ROOT_PASSWORD: ${QUESTION_DB_PASSWORD}
35-
volumes:
36-
- question-db:/data/db
37-
- ./services/question/init-mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
38-
networks:
39-
- question-db-network
40-
command: --quiet
41-
restart: always
42-
4328
user:
4429
container_name: user
4530
image: user

services/question/.env.sample

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# This is a sample environment configuration file.
22
# Copy this file to .env and replace the placeholder values with your own.
3-
DB_CLOUD_URI=<FILL-THIS-IN>
4-
DB_LOCAL_URI=mongodb://question-db:27017/question
3+
DB_URI=<FILL-THIS-IN>
54
DB_USERNAME=user
65
DB_PASSWORD=password
76
CORS_ORIGIN=*

services/question/src/models/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import mongoose from 'mongoose';
22
import { IQuestion, Question } from './questionModel';
33

44
export async function connectToDB() {
5-
const mongoURI = process.env.NODE_ENV === 'production' ? process.env.DB_CLOUD_URI : process.env.DB_LOCAL_URI;
5+
const mongoURI = process.env.DB_URI;
66

77
console.log('MongoDB URI:', mongoURI);
88

0 commit comments

Comments
 (0)