Skip to content

Commit 8667e8e

Browse files
committed
fix docker db connection
1 parent fe7c740 commit 8667e8e

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ DB_MAX_POOL_SIZE=5
2121
#localhost or IP of the server
2222
# If using the docker installation then use 'mongo' for host name else localhost or ip or db server
2323
#YOUR_MONGO_DB_HOST_NAME
24-
DB_HOST=localhost
24+
DB_HOST=mongo
2525

2626
DB_PORT=27017
2727

@@ -36,8 +36,8 @@ DB_ADMIN=admin
3636
DB_ADMIN_PWD=changeit
3737

3838
# Redis
39-
REDIS_CACHE_PORT=
40-
REDIS_CACHE_PASSWORD=
39+
REDIS_CACHE_PORT=6379
40+
REDIS_CACHE_PASSWORD=changeit
4141

4242
# Log
4343
# Example '/home/node/logs'

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '1'
1+
version: '3.9'
22

33
services:
44
app:
@@ -21,6 +21,9 @@ services:
2121
links:
2222
- mongo
2323
- redis
24+
depends_on:
25+
- mongo
26+
- redis
2427

2528
mongo:
2629
# To create this service, Compose will pull the mongo
@@ -54,7 +57,7 @@ services:
5457
ports:
5558
- '$REDIS_CACHE_PORT:6379'
5659
command: redis-server --save 20 1 --loglevel warning --requirepass $REDIS_CACHE_PASSWORD
57-
volumes:
60+
volumes:
5861
- cache:/data/cache
5962

6063
# Our top-level volumes key defines the volumes dbdata.

src/database/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function setRunValidators() {
2121
this.setOptions({ runValidators: true });
2222
}
2323

24+
mongoose.set('strictQuery', true);
25+
2426
// Create the database connection
2527
mongoose
2628
.plugin((schema: any) => {
@@ -60,4 +62,4 @@ process.on('SIGINT', () => {
6062
Logger.info('Mongoose default connection disconnected through app termination');
6163
process.exit(0);
6264
});
63-
});
65+
});

tests/.env.test.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DB_MAX_POOL_SIZE=5
2020

2121
#localhost or IP of the server
2222
# YOUR_TEST_MONGO_DB_HOST_NAME
23-
DB_HOST=localhost
23+
DB_HOST=mongo
2424

2525
DB_PORT=27017
2626

0 commit comments

Comments
 (0)