Skip to content

Commit 611e75d

Browse files
author
Max Azatian
committed
SEC 1.6: mongodb login creds added
1 parent 95eef81 commit 611e75d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.github/workflows/tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ jobs:
3838
# For the backend service
3939
yq eval '.services.backend.extra_hosts += ["host.docker.internal:host-gateway"]' -i docker-compose.ci.yaml
4040
yq eval '.services.backend.environment += ["TESTING=true"]' -i docker-compose.ci.yaml
41+
yq eval '.services.backend.environment += ["MONGO_ROOT_USER=testroot"]' -i docker-compose.ci.yaml
42+
yq eval '.services.backend.environment += ["MONGO_ROOT_PASSWORD=testpassword"]' -i docker-compose.ci.yaml
43+
44+
# For the mongo service
45+
yq eval '.services.mongo.environment += ["MONGO_ROOT_USER=testroot"]' -i docker-compose.ci.yaml
46+
yq eval '.services.mongo.environment += ["MONGO_ROOT_PASSWORD=testpassword"]' -i docker-compose.ci.yaml
4147
4248
# For the cert-generator service
4349
yq eval '.services.cert-generator.extra_hosts += ["host.docker.internal:host-gateway"]' -i docker-compose.ci.yaml

docker-compose.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ services:
3232
image: mongo:4.4
3333
ports:
3434
- "27017:27017"
35+
environment:
36+
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USER:-root}
37+
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD:-rootpassword}
38+
MONGO_INITDB_DATABASE: integr8scode
3539
volumes:
3640
- mongo_data:/data/db
3741
networks:
3842
- app-network
3943
container_name: mongo
4044
healthcheck:
41-
test: echo 'db.runCommand("ping").ok' | mongo --quiet
45+
test: echo 'db.runCommand("ping").ok' | mongo localhost/integr8scode -u ${MONGO_ROOT_USER:-root} -p ${MONGO_ROOT_PASSWORD:-rootpassword} --authenticationDatabase admin --quiet
4246
interval: 10s
4347
timeout: 10s
4448
retries: 5
@@ -63,7 +67,7 @@ services:
6367
- app-network
6468
container_name: backend
6569
environment:
66-
- MONGODB_URL=mongodb://mongo:27017/integr8scode
70+
- MONGODB_URL=mongodb://${MONGO_ROOT_USER:-root}:${MONGO_ROOT_PASSWORD:-rootpassword}@mongo:27017/integr8scode?authSource=admin
6771
- SERVER_HOST=0.0.0.0
6872
healthcheck:
6973
test: [ "CMD", "curl", "-k", "https://localhost/api/v1/health" ]

0 commit comments

Comments
 (0)