Skip to content

Added database import logic#3

Merged
LightJack05 merged 1 commit intomainfrom
database-import
Jan 15, 2026
Merged

Added database import logic#3
LightJack05 merged 1 commit intomainfrom
database-import

Conversation

@LightJack05
Copy link
Contributor

No description provided.

@LightJack05 LightJack05 self-assigned this Jan 15, 2026
Copilot AI review requested due to automatic review settings January 15, 2026 12:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'.

Suggested change
# Restore from the mounted /dump folder
# Restore from the archive mounted at the root level as openfoodfacts-mongodbdump.gz

Copilot uses AI. Check for mistakes.
- 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
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: database_api_wrapper
MONGO_INITDB_ROOT_PASSWORD: d812d430-de21-413d-9630-47ff5a5b3daa
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
interval: 10s
timeout: 5s
retries: 5
start_period: 120s
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
start_period: 120s
start_period: 30s

Copilot uses AI. Check for mistakes.
@LightJack05 LightJack05 merged commit 873c9d3 into main Jan 15, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant