Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve base .env file to make it OFF independent #77

Merged
merged 1 commit into from
Jan 17, 2024
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
30 changes: 15 additions & 15 deletions .env
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
# This envvar is **required**
CONFIG_PATH=
54 changes: 54 additions & 0 deletions .env.openfoodfacts
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions .github/workflows/container-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions TODO.md

This file was deleted.

1 change: 1 addition & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions app/utils/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -94,7 +95,7 @@ services:
api:
<<: *api-common
ports:
- "${SEARCH_PORT}:8000"
- "${SEARCH_EXPOSE}:8000"

# service listening to redis for updates
updater:
Expand Down
2 changes: 1 addition & 1 deletion docker/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading