diff --git a/docker-compose.yml b/docker-compose.yml index 07b84e2..1bfc8d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,29 +3,35 @@ version: '3.8' services: factsdb: build: . - container_name: factsdb ports: - - "21:21" - "5000:5000" + - "2121:2121" volumes: - - ./data:/app/data - ./facts.db:/app/facts.db + - ./data:/app/data environment: - - AI_ENDPOINT_URL=http://example.com:4000 + - FTP_HOST=0.0.0.0 + - FTP_PORT=2121 + - FTP_USERNAME=factsdb + - FTP_PASSWORD=factsdb + - AI_ENDPOINT_URL=http://example.com:4000/v1/chat/completions - AI_ENDPOINT_TOKEN=111 - - FTP_ROOT_DIR=/app/ftp_data - networks: - - factsdb-network + - DATABASE_PATH=/app/facts.db + restart: unless-stopped + command: python -m factsdb.main api - # Optional: Add a database service for persistence - # db: - # image: sqlite:latest - # container_name: factsdb-db + # Optional: Add a separate service for FTP if needed + # ftp: + # build: . + # ports: + # - "2121:2121" # volumes: - # - ./db_data:/var/lib/sqlite - # networks: - # - factsdb-network - -networks: - factsdb-network: - driver: bridge \ No newline at end of file + # - ./facts.db:/app/facts.db + # - ./data:/app/data + # environment: + # - FTP_HOST=0.0.0.0 + # - FTP_PORT=2121 + # - FTP_USERNAME=factsdb + # - FTP_PASSWORD=factsdb + # restart: unless-stopped + # command: python -m factsdb.main ftp \ No newline at end of file diff --git a/factsdb/config.py b/factsdb/config.py index c667713..4cce70d 100644 --- a/factsdb/config.py +++ b/factsdb/config.py @@ -1,64 +1,56 @@ """ -Configuration management for FactsDB service +Configuration module for FactsDB service +Loads configuration from environment variables """ import os from dataclasses import dataclass from typing import Optional -@dataclass -class AIEndpointConfig: - """Configuration for AI endpoint""" - url: str = "http://example.com:4000" - auth_token: str = "111" - default_model: str = "gpt-oss" - @dataclass class DatabaseConfig: """Database configuration""" - type: str = "sqlite" - connection_string: str = "facts.db" + path: str = "facts.db" @dataclass -class FTPConfig: +class AIEndpointConfig: + """AI endpoint configuration""" + url: str = "http://example.com:4000/v1/chat/completions" + auth_token: str = "111" + +@dataclass +class FTPServerConfig: """FTP server configuration""" host: str = "0.0.0.0" - port: int = 21 + port: int = 2121 username: str = "factsdb" - password: str = "factsdb123" - root_directory: str = "/tmp/factsdb_ftp" + password: str = "factsdb" @dataclass -class FileOnboardingConfig: - """Configuration for file onboarding""" - directory_path: str - table_name: str - prompt: str - ai_model: str = "gpt-oss" - database_type: str = "sqlite" - cache_file: str = ".factsdb_cache" +class SchedulerConfig: + """Scheduler configuration""" + interval_minutes: int = 10 class Config: """Main configuration class""" def __init__(self): - self.ai_endpoint = AIEndpointConfig( - url=os.getenv("AI_ENDPOINT_URL", "http://example.com:4000"), - auth_token=os.getenv("AI_ENDPOINT_TOKEN", "111"), - default_model=os.getenv("DEFAULT_AI_MODEL", "gpt-oss") - ) - self.database = DatabaseConfig( - type=os.getenv("DB_TYPE", "sqlite"), - connection_string=os.getenv("DB_CONNECTION", "facts.db") + path=os.getenv('DATABASE_PATH', 'facts.db') ) - self.ftp = FTPConfig( - host=os.getenv("FTP_HOST", "0.0.0.0"), - port=int(os.getenv("FTP_PORT", "21")), - username=os.getenv("FTP_USERNAME", "factsdb"), - password=os.getenv("FTP_PASSWORD", "factsdb123"), - root_directory=os.getenv("FTP_ROOT_DIR", "/tmp/factsdb_ftp") + self.ai_endpoint = AIEndpointConfig( + url=os.getenv('AI_ENDPOINT_URL', 'http://example.com:4000/v1/chat/completions'), + auth_token=os.getenv('AI_ENDPOINT_TOKEN', '111') ) - self.cache_file = os.getenv("CACHE_FILE", ".factsdb_cache") \ No newline at end of file + self.ftp_server = FTPServerConfig( + host=os.getenv('FTP_HOST', '0.0.0.0'), + port=int(os.getenv('FTP_PORT', '2121')), + username=os.getenv('FTP_USERNAME', 'factsdb'), + password=os.getenv('FTP_PASSWORD', 'factsdb') + ) + + self.scheduler = SchedulerConfig( + interval_minutes=int(os.getenv('SCHEDULER_INTERVAL', '10')) + ) \ No newline at end of file