Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.git
.github
.gitignore

flake.nix
flake.lock
Makefile
README.md

*.exe
*.test
*.out
coverage.*
.env
data/
data-clean/
openfoodfacts-mongodbdump.gz
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ go.work.sum
# .vscode/
data/
data-clean/
openfoodfacts-mongodbdump.gz
22 changes: 22 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,35 @@ services:
- SERVICE_CONFIG_APP_NAME=SnackLog
- 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.
- GIN_MODE=debug
build: .
ports:
- 8080:80
depends_on:
mongodb:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:80/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5

mongodb:
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.
volumes:
- ./openfoodfacts-mongodbdump.gz:/openfoodfacts-mongodbdump.gz:ro
- ./restore_db.sh:/docker-entrypoint-initdb.d/restore.sh:ro
- ./data/mongo/:/data/db:rw
ports:
- "27017:27017"
healthcheck:
test: ["CMD-SHELL", "mongosh --quiet --username $$MONGO_INITDB_ROOT_USERNAME --password $$MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin --eval \"db.adminCommand('ping')\""]
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.
4 changes: 4 additions & 0 deletions restore_db.sh
Original file line number Diff line number Diff line change
@@ -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.
# We use the env vars provided in compose to authenticate
mongorestore --username "$MONGO_INITDB_ROOT_USERNAME" --password "$MONGO_INITDB_ROOT_PASSWORD" --authenticationDatabase admin --archive=openfoodfacts-mongodbdump.gz --gzip
Loading