Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds MongoDB database initialization infrastructure to support importing data from a dump file. The changes introduce a MongoDB service container, database restore automation, and environment variable configuration for database authentication.
Changes:
- Added MongoDB service to docker-compose with health checks and volume mounts
- Created restore script to automatically import database dump on initialization
- Updated gitignore and dockerignore to exclude the database dump file
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| restore_db.sh | Shell script to restore MongoDB from dump file using mongorestore |
| docker-compose.yaml | Added MongoDB service with credentials, volumes, health checks, and service dependency configuration |
| .gitignore | Excluded database dump file from version control |
| .dockerignore | Excluded database dump file from Docker build context |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,4 @@ | |||
| #!/bin/bash | |||
| # Restore from the mounted /dump folder | |||
There was a problem hiding this comment.
The comment references '/dump folder' but the script uses the archive file directly from the root directory. The comment should be updated to reflect that the archive is mounted at the root level as 'openfoodfacts-mongodbdump.gz'.
| # Restore from the mounted /dump folder | |
| # Restore from the archive mounted at the root level as openfoodfacts-mongodbdump.gz |
| - SERVICE_CONFIG_API_ROOT_URL=localhost | ||
| - SERVICE_CONFIG_SERVICE_NAME=database-api-wrapper | ||
| - MONGO_INITDB_ROOT_USERNAME=database_api_wrapper | ||
| - MONGO_INITDB_ROOT_PASSWORD=d812d430-de21-413d-9630-47ff5a5b3daa |
There was a problem hiding this comment.
Database credentials are hardcoded in the docker-compose file. For production use, these should be moved to environment variables or a secrets management system. Consider using an .env file that is not committed to version control.
| image: mongo:latest | ||
| environment: | ||
| MONGO_INITDB_ROOT_USERNAME: database_api_wrapper | ||
| MONGO_INITDB_ROOT_PASSWORD: d812d430-de21-413d-9630-47ff5a5b3daa |
There was a problem hiding this comment.
Database credentials are hardcoded in the docker-compose file. For production use, these should be moved to environment variables or a secrets management system. Consider using an .env file that is not committed to version control.
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
| start_period: 120s |
There was a problem hiding this comment.
The health check start_period of 120 seconds (2 minutes) is quite long. This delays the dependent service from starting. If the database restore is expected to be fast or if the database is already initialized, consider reducing this value to improve startup time.
| start_period: 120s | |
| start_period: 30s |
No description provided.