diff --git a/.env b/.env index 8e95a39c..117c50bf 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ -# set project name to have a short one -COMPOSE_PROJECT_NAME=po_search +# set a short project name, all containers will be prefixed with this name +COMPOSE_PROJECT_NAME=search # unify separator with windows style COMPOSE_PATH_SEPARATOR=; # dev is default target @@ -14,14 +14,16 @@ CLUSTER_NAME=docker-cluster # Set to 'basic' or 'trial' to automatically start the 30-day trial # LICENSE=basic -# Exposing some services to the host -SEARCH_PORT=127.0.0.1:8000 -ES_VUE_PORT=127.0.0.1:8080 -# this service needs to be accessible by product opener -# this means publishing it if we are on another machine -REDIS_PORT=127.0.0.1:6379 -# exposures for dev -ES_PORT=127.0.0.1:9200 +# Exposing search API and es-vue services to the host +SEARCH_EXPOSE=127.0.0.1:8000 +ES_VUE_EXPOSE=127.0.0.1:8080 + +# Redis configuration +REDIS_HOST=redis +REDIS_PORT=6379 + +# Expose elasticsearch for dev +ES_EXPOSE=127.0.0.1:9200 # eventually add basic auth for nginx # set to a user:apr1 password (as found in htaccess) if you want to us auth @@ -39,14 +41,12 @@ MEM_LIMIT=4294967296 # on dev connect to the same network as off-server COMMON_NET_NAME=po_default -# Sentry DNS for bug tracking, used only in staging and production +# Sentry DNS for bug tracking SENTRY_DNS= # Log level to use, DEBUG by default in dev LOG_LEVEL=DEBUG # Path to the yaml configuration file -CONFIG_PATH=data/config/openfoodfacts.yml - -# URL to the OFF API -OFF_API_URL=https://world.openfoodfacts.org \ No newline at end of file +# This envvar is **required** +CONFIG_PATH= \ No newline at end of file diff --git a/.env.openfoodfacts b/.env.openfoodfacts new file mode 100644 index 00000000..f0a631da --- /dev/null +++ b/.env.openfoodfacts @@ -0,0 +1,54 @@ +# set project name to have a short one +COMPOSE_PROJECT_NAME=po_search +# unify separator with windows style +COMPOSE_PATH_SEPARATOR=; +# dev is default target +COMPOSE_FILE=docker-compose.yml;docker/dev.yml + +# Version of Elastic products +STACK_VERSION=8.3.3 + +# Set the cluster name +CLUSTER_NAME=docker-cluster + +# Set to 'basic' or 'trial' to automatically start the 30-day trial +# LICENSE=basic + +# Exposing search API and es-vue services to the host +SEARCH_EXPOSE=127.0.0.1:8000 +ES_VUE_EXPOSE=127.0.0.1:8080 + +# Redis configuration +REDIS_HOST=redis +REDIS_PORT=6379 + +# Expose elasticsearch for dev +ES_EXPOSE=127.0.0.1:9200 + +# eventually add basic auth for nginx +# set to a user:apr1 password (as found in htaccess) if you want to us auth +# you can generate one with docker run --rm httpd:latest htpasswd -nb USER PASSWORD +# warning: if you change it, you need to remove / recreate the elasticvue container +NGINX_BASIC_AUTH_USER_PASSWD= + +# by default on dev desktop, no restart +RESTART_POLICY=no + +# Increase or decrease based on the available host memory (in bytes) +# 1GB works well, 2GB and above leads to lower latency +MEM_LIMIT=4294967296 + +# on dev connect to the same network as off-server +COMMON_NET_NAME=po_default + +# Sentry DNS for bug tracking, used only in staging and production +SENTRY_DNS= + +# Log level to use, DEBUG by default in dev +LOG_LEVEL=DEBUG + +# Path to the yaml configuration file +CONFIG_PATH=data/config/openfoodfacts.yml + +# URL to the OFF API +OFF_API_URL=https://world.openfoodfacts.org \ No newline at end of file diff --git a/.github/workflows/container-deploy.yml b/.github/workflows/container-deploy.yml index 98f39747..6e40b556 100644 --- a/.github/workflows/container-deploy.yml +++ b/.github/workflows/container-deploy.yml @@ -114,14 +114,14 @@ jobs: echo "COMPOSE_PATH_SEPARATOR=;" >> .env echo "COMPOSE_FILE=docker-compose.yml;docker/prod.yml" >> .env # Copy variables that are same as dev - grep '\(STACK_VERSION\|ES_PORT\)' .env-dev >> .env + grep '\(STACK_VERSION\|ES_EXPOSE\)' .env-dev >> .env # Set docker variables echo "TAG=sha-${{ github.sha }}" >> .env echo "RESTART_POLICY=always" >> .env # Set App variables echo "CLUSTER_NAME=${{ matrix.env }}-es-cluster" >> .env - echo "SEARCH_PORT=8180" >> .env - echo "ES_VUE_PORT=8181" >> .env + echo "SEARCH_EXPOSE=8180" >> .env + echo "ES_VUE_EXPOSE=8181" >> .env echo "REDIS_PORT=8182" >> .env echo "MEM_LIMIT=4294967296" >> .env # this is the network shared with productopener diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 98aa68ba..00000000 --- a/TODO.md +++ /dev/null @@ -1,2 +0,0 @@ -1. Index taxonomies in separate indices and allow to do search-as-you-type on taxonomies -2. Fix luqum parser that search in "text" field when searching: '"match phrase"' \ No newline at end of file diff --git a/app/config.py b/app/config.py index addb741b..f9097518 100644 --- a/app/config.py +++ b/app/config.py @@ -38,6 +38,7 @@ class Settings(BaseSettings): redis_reader_timeout: int = 5 elasticsearch_url: str = "http://localhost:9200" redis_host: str = "localhost" + redis_port: int = 6379 # the name of the Redis stream to read from when listening to product # updates redis_import_stream_name: str = "product_update" diff --git a/app/utils/connection.py b/app/utils/connection.py index e51637e4..9f96938e 100644 --- a/app/utils/connection.py +++ b/app/utils/connection.py @@ -13,7 +13,7 @@ def get_es_client(**kwargs): def get_redis_client() -> Redis: return Redis( - host="redis", - port=6379, + host=settings.redis_host, + port=settings.redis_port, decode_responses=True, ) diff --git a/docker-compose.yml b/docker-compose.yml index 850f9c36..25b65471 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,9 +39,10 @@ x-api-common: &api-common restart: ${RESTART_POLICY} environment: - ELASTICSEARCH_URL=http://es01:9200 - - REDIS_HOST=redis - SENTRY_DNS - LOG_LEVEL + - REDIS_HOST + - REDIS_PORT # Directory where we cache downloaded taxonomies files - TAXONOMY_CACHE_DIR # Path of the yaml configuration file @@ -83,7 +84,7 @@ services: environment: - NGINX_BASIC_AUTH_USER_PASSWD ports: - - "${ES_VUE_PORT}:8080" + - "${ES_VUE_EXPOSE}:8080" volumes: # we add an entrypoint to eventually add basic auth - ./docker/elasticvue-entrypoint.sh:/bin/elasticvue-entrypoint.sh:ro @@ -94,7 +95,7 @@ services: api: <<: *api-common ports: - - "${SEARCH_PORT}:8000" + - "${SEARCH_EXPOSE}:8000" # service listening to redis for updates updater: diff --git a/docker/dev.yml b/docker/dev.yml index 62fb4589..dbf38a31 100644 --- a/docker/dev.yml +++ b/docker/dev.yml @@ -22,7 +22,7 @@ x-api-base: &api-base services: es01: ports: - - "${ES_PORT}:9200" + - "${ES_EXPOSE}:9200" api: <<: *api-base # uvicorn in reload mode