Skip to content

Commit

Permalink
fix: off url from env (#22)
Browse files Browse the repository at this point in the history
* build: use uvicorn reload in dev
* fix: off url in env
  • Loading branch information
alexgarel authored Oct 19, 2022
1 parent 90f708a commit eeba4c4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ MEM_LIMIT=4294967296

# on dev connect to the same network as off-server
COMMON_NET_NAME=po_default
OPENFOODFACTS_API_URL=http://world.openfoodfacts.localhost
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ livecheck:

build:
@echo "🥫 building docker (for dev)"
docker-compose build
docker-compose build
14 changes: 6 additions & 8 deletions app/import_queue/product_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@


class ProductClient:

def __init__(self):
pass
self.server_url = os.getenv(
'OPENFOODFACTS_API_URL',
'https://world.openfoodfacts.org',
)

def get_product(self, code):
url = '{}/api/v2/product/{}'.format(
os.getenv(
'OPENFOODFACTS_API_URL',
'https://world.openfoodfacts.org',
),
code,
)
url = f'{self.server_url}/api/v2/product/{code}'
response = requests.get(url)
json_response = response.json()
if not json_response or not json_response.get('product'):
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ services:
environment:
- ELASTICSEARCH_URL=es01:9200
- REDIS_HOST=searchredis
- OPENFOODFACTS_API_URL
# make it easier to run scripts
- PYTHONPATH=/code
ports:
Expand Down
1 change: 1 addition & 0 deletions docker/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ services:
volumes:
# mount code dynamically
- "./app:/code/app"
command: ["uvicorn", "app.api:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "8000", "--reload"]
2 changes: 1 addition & 1 deletion docker/elasticvue-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ then
sed -i "/^ *access_log .*/r /tmp/nginx_snipet" $NGINX_CONF
fi

exec "$@"
exec "$@"
2 changes: 1 addition & 1 deletion docker/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ volumes:
networks:
common_net:
name: ${COMMON_NET_NAME}
external: true
external: true

0 comments on commit eeba4c4

Please sign in to comment.