-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1505 from wger-project/feature/import-off-products
Improve Open Food Facts import
- Loading branch information
Showing
7 changed files
with
259 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Import Open Food Facts products | ||
|
||
This docker compose helps import or update products from the Open Food Facts | ||
database into wger. | ||
|
||
Note that the OFF database dump is very large, and you will need several times | ||
this size available on your computer (tar.gz-file, extracted dump, mongo). | ||
|
||
## 1 | ||
|
||
Download a current dump of their database | ||
|
||
```shell | ||
cd dump | ||
wget https://static.openfoodfacts.org/data/openfoodfacts-mongodbdump.tar.gz | ||
tar xzvf openfoodfacts-mongodbdump.tar.gz | ||
``` | ||
|
||
## 2 | ||
|
||
Import the data into mongo. | ||
|
||
Note that we are running this as a manual step since the import takes a while | ||
|
||
```shell | ||
docker compose up | ||
docker compose exec mongodb mongorestore --username off --password off-wger -d admin -c products /dump/dump/off/products.bson | ||
``` | ||
|
||
There is also an admin interface available at <http://localhost:8081>, log in with | ||
these credentials: | ||
|
||
* admin | ||
* pass | ||
|
||
## 3 | ||
|
||
Run the import script | ||
|
||
```shell | ||
python manage.py import-off-products | ||
``` | ||
|
||
## 4 | ||
|
||
Don't forget to delete the dump and remove the containers if you love your | ||
hard disk | ||
|
||
```shell | ||
docker compose down | ||
rm dump -r openfoodfacts-mongodbdump.tar.gz dump/dump | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
services: | ||
mongodb: | ||
image: mongo | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- $PWD/dump:/dump | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: off | ||
MONGO_INITDB_ROOT_PASSWORD: off-wger | ||
|
||
mongo-express: | ||
image: mongo-express | ||
restart: always | ||
ports: | ||
- 8081:8081 | ||
environment: | ||
ME_CONFIG_MONGODB_ADMINUSERNAME: off | ||
ME_CONFIG_MONGODB_ADMINPASSWORD: off-wger | ||
ME_CONFIG_MONGODB_URL: mongodb://off:off-wger@mongodb:27017/ |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.