Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Added a default MongoDB password to the Docker test image
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLeChat committed Jan 30, 2024
1 parent 7e11f93 commit 0ff6f95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ USER node

# Find and replace the database host and password
RUN sed -i "s/MONGODB_HOST=127.0.0.1/MONGODB_HOST=mongo/g" .env
RUN sed -i "s/MONGODB_PASSWORD=password/MONGODB_PASSWORD=$(cat /usr/src/app/docker/config/db_root_password.txt | tr -d '\n')/g" .env
RUN if [ -f "docker/config/db_root_password.txt" ]; then \
sed -i "s/MONGODB_PASSWORD=password/MONGODB_PASSWORD=$(cat /usr/src/app/docker/config/db_root_password.txt)/g" .env; \
fi

# Build the entire project
RUN npm run build
Expand Down
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ services:
- db_root_password
# entrypoint: ["mongod", "--config", "/etc/mongo/mongod.conf"]
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
MONGO_INITDB_DATABASE: domego
MONGO_INITDB_ROOT_USERNAME: root
# > Default credentials (for test image)
MONGO_INITDB_ROOT_PASSWORD: password
# > Custom credentials with secrets (for production image)
# MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
networks:
- domego
ports:
Expand Down

0 comments on commit 0ff6f95

Please sign in to comment.