Skip to content

Commit

Permalink
Replace host nework with service name url, use correct FIA_API_URL in…
Browse files Browse the repository at this point in the history
… load_rules, fix healthcheck fia-api service,

To make the run-detection container run without crashing. Related commits in fia-api #384 622f24b599d1f6a113dbbe9dbc3b2fef1eaf8dfe
  • Loading branch information
HumzahJavid committed Sep 4, 2024
1 parent fd07adc commit c2a6709
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
7 changes: 3 additions & 4 deletions rundetection/specifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
import logging
import os
import typing
from pathlib import Path

Expand All @@ -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:
Expand All @@ -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
)
Expand Down
20 changes: 9 additions & 11 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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"

Expand All @@ -74,8 +77,3 @@ services:
interval: 10s
timeout: 5s
retries: 10

networks:
bridge_net:
external: true
driver: bridge

0 comments on commit c2a6709

Please sign in to comment.