From c2a67094045bdcee61911abfde5a1dd5fa8bda07 Mon Sep 17 00:00:00 2001 From: HumzahJavid <25638011+HumzahJavid@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:18:18 +0100 Subject: [PATCH] Replace host nework with service name url, use correct FIA_API_URL in load_rules, fix healthcheck fia-api service, To make the run-detection container run without crashing. Related commits in fia-api #384 622f24b599d1f6a113dbbe9dbc3b2fef1eaf8dfe --- rundetection/specifications.py | 7 +++---- test/docker-compose.yml | 20 +++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/rundetection/specifications.py b/rundetection/specifications.py index ec02d9c..23f49e7 100644 --- a/rundetection/specifications.py +++ b/rundetection/specifications.py @@ -4,6 +4,7 @@ import json import logging +import os import typing from pathlib import Path @@ -21,8 +22,8 @@ logger = logging.getLogger(__name__) FIA_API_API_KEY = "shh" -FIA_API_URL = "http://localhost:8000" -headers: json = {"Authorization": f"Bearer {FIA_API_API_KEY}", "accept": "application/json"} +FIA_API_URL = os.getenv("FIA_API_URL", "http://localhost:8000") +headers: dict = {"Authorization": f"Bearer {FIA_API_API_KEY}", "accept": "application/json"} class InstrumentSpecification: @@ -38,8 +39,6 @@ def __init__(self, instrument: str) -> None: self._load_rules() def _load_rules(self) -> None: - # get specification via FIA_API - logger.debug(f"FIA_API_URL =********************* {FIA_API_URL}, {self._instrument}") requests.get( url=f"{FIA_API_URL}/instrument/{self._instrument.upper()}/specification", headers=headers, timeout=1000 ) diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 570ffcf..696ecf7 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -25,6 +25,8 @@ services: fia_api: condition: service_healthy environment: + FIA_API_URL: http://fia_api + FIA_API_API_KEY: shh QUEUE_HOST: 'rabbit-mq' INGRESS_QUEUE_NAME: 'watched-files' EGRESS_QUEUE_NAME: 'scheduled-jobs' @@ -33,28 +35,29 @@ services: fia_api: build: - context: ../../FIA-API + context: ../FIA-API dockerfile: container/fia_api.D container_name: fia_api image: ghcr.io/fiaisis/fia-api - network_mode: host ports: - '8000:80' depends_on: db: condition: service_healthy healthcheck: - test: curl --fail -X 'GET' 'http://localhost:8000/healthz' || exit 1 + test: curl --fail 'http://localhost:80/healthz' || exit 1 interval: 30s timeout: 30s retries: 3 environment: + DB_IP: db FIA_API_API_KEY: shh + DEV_MODE: 'True' command: bash -c " - pip install .[all] + apt-get update + && apt-get -y install curl + && pip install .[all] && pip install .[test] - && pwd - && ls -a && python -m utils.db_generator && uvicorn fia_api.fia_api:app --host 0.0.0.0 --port 80" @@ -74,8 +77,3 @@ services: interval: 10s timeout: 5s retries: 10 - -networks: - bridge_net: - external: true - driver: bridge