Skip to content

Commit

Permalink
fix: run off-pro through docker (#9956)
Browse files Browse the repository at this point in the history
Somes changes to try to get "make dev" work after running `. env/setenv.sh off-pro`:
* The sftp folder is created in order to avoid having an error at startup:
* And we skip the import_sample_data

---------

Co-authored-by: Alex Garel <alex@openfoodfacts.org>
  • Loading branch information
stephanegigandet and alexgarel authored Mar 26, 2024
1 parent c93909c commit f18fb74
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ RUN \
RUN \
mkdir -p var/run/apache2/ && \
chown www-data:www-data var/run/apache2/ && \
for path in data html_data users products product_images orgs logs new_images deleted_products_images reverted_products deleted_private_products translate deleted_products deleted.images import_files tmp build-cache/taxonomies debug; do \
for path in data html_data users products product_images orgs logs new_images deleted_products_images reverted_products deleted_private_products translate deleted_products deleted.images import_files tmp build-cache/taxonomies debug sftp; do \
mkdir -p /mnt/podata/${path}; \
done && \
chown www-data:www-data -R /mnt/podata && \
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ edit_etc_hosts:
create_folders:
# create some folders to avoid having them owned by root (when created by docker compose)
@echo "🥫 Creating folders before docker compose use them."
mkdir -p logs/apache2 logs/nginx debug html/data || ( whoami; ls -l . ; false )
mkdir -p logs/apache2 logs/nginx debug html/data sftp || ( whoami; ls -l . ; false )

# TODO: Figure out events => actions and implement live reload
# live_reload:
Expand Down Expand Up @@ -205,9 +205,13 @@ refresh_product_tags:
${DOCKER_COMPOSE} run --rm backend perl /opt/product-opener/scripts/refresh_postgres.pl ${from}

import_sample_data:
@echo "🥫 Importing sample data (~200 products) into MongoDB …"
${DOCKER_COMPOSE} run --rm backend bash /opt/product-opener/scripts/import_sample_data.sh

@ if [[ "${PRODUCT_OPENER_FLAVOR_SHORT}" = "off" && "${PRODUCERS_PLATFORM}" != "1" ]]; then \
echo "🥫 Importing sample data (~200 products) into MongoDB …"; \
${DOCKER_COMPOSE} run --rm backend bash /opt/product-opener/scripts/import_sample_data.sh; \
else \
echo "🥫 Not importing sample data into MongoDB (only for po_off project)"; \
fi

import_more_sample_data:
@echo "🥫 Importing sample data (~2000 products) into MongoDB …"
${DOCKER_COMPOSE} run --rm backend bash /opt/product-opener/scripts/import_more_sample_data.sh
Expand Down
2 changes: 2 additions & 0 deletions docker/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ x-backend-conf: &backend-conf
- ./docker/docker-entrypoint.sh:/docker-entrypoint.sh
# we use this for debugging, from times to times
- ./debug:/mnt/podata/debug/
# sftp folder for the pro platform
- ./sftp:/mnt/podata/sftp/
# Allow the container to connect to the host when using Linux.
# This is needed to access other services that are running outside of Docker
# e.g. when developing with Robotoff or openfoodfacts-query
Expand Down
5 changes: 2 additions & 3 deletions lib/ProductOpener/GS1.pm
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ sub normalize_gs1_maps_entries() {
$log->error("gs1_maps - entry not in taxonomy",
{tagtype => "allergens", tag => $gs1_maps{allergenTypeCode}{$tag}})
if $log->is_error();
print STDERR "tag: $tag - canon_tag: $canon_tag\n";
die;
die("gs1_maps - entry not in taxonomy - tagtype: allergens - tag: $tag - canon_tag: $canon_tag");
}
}

Expand All @@ -360,7 +359,7 @@ sub normalize_gs1_maps_entries() {
$log->error("gs1_maps - entry not in taxonomy",
{tagtype => "labels", tag => $gs1_maps{packagingMarkedLabelAccreditationCode}{$tag}})
if $log->is_error();
die;
die("gs1_maps - entry not in taxonomy - tagtype: labels - tag: $tag - canon_tag: $canon_tag");
}
}

Expand Down

0 comments on commit f18fb74

Please sign in to comment.