docker deploy of backend now working

This commit is contained in:
martin legrand
2025-05-31 22:01:42 +02:00
parent a3b0bb22aa
commit be1bfc5cf2
4 changed files with 15 additions and 24 deletions
-5
View File
@@ -2,9 +2,6 @@
FROM --platform=linux/amd64 python:3.11-slim FROM --platform=linux/amd64 python:3.11-slim
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
#RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome
#USER chrome
# Install essential packages and Chrome dependencies # Install essential packages and Chrome dependencies
RUN apt-get update -y && apt-get install -y \ RUN apt-get update -y && apt-get install -y \
wget \ wget \
@@ -102,7 +99,5 @@ COPY config.ini .
EXPOSE 8000 EXPOSE 8000
#RUN chown -R chrome:chrome /app
#RUN chown -R chrome:chrome /tmp
# Run the application # Run the application
CMD ["python3", "api.py"] CMD ["python3", "api.py"]
+1 -1
View File
@@ -84,7 +84,7 @@ services:
environment: environment:
- SEARXNG_URL=${SEARXNG_BASE_URL:-http://searxng:8080} - SEARXNG_URL=${SEARXNG_BASE_URL:-http://searxng:8080}
- REDIS_URL=${REDIS_BASE_URL:-redis://redis:6379/0} - REDIS_URL=${REDIS_BASE_URL:-redis://redis:6379/0}
- WORK_DIR_HOST=${WORK_DIR_HOST:-.} - WORK_DIR=/opt/workspace
- OPENAI_API_KEY=${OPENAI_API_KEY} - OPENAI_API_KEY=${OPENAI_API_KEY}
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY} - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY} - OPENROUTER_API_KEY=${OPENROUTER_API_KEY}
+1
View File
@@ -42,6 +42,7 @@ selenium_stealth>=1.0.6
undetected-chromedriver>=3.5.5 undetected-chromedriver>=3.5.5
sentencepiece>=0.2.0 sentencepiece>=0.2.0
python-dotenv>=1.0.0 python-dotenv>=1.0.0
together>=1.5.0
tqdm>4 tqdm>4
openai openai
sniffio sniffio
+12 -17
View File
@@ -50,19 +50,15 @@ class Tools():
def set_allow_language_exec_bash(value: bool) -> None: def set_allow_language_exec_bash(value: bool) -> None:
self.allow_language_exec_bash = value self.allow_language_exec_bash = value
def check_config_dir_validity(self): def safe_get_work_dir_path(self):
"""Check if the config directory is valid.""" path = None
path = self.config['MAIN']['work_dir'] path = os.getenv('WORK_DIR', path)
if path == "": if path is None or path == "":
print("WARNING: Work directory not set in config.ini") path = self.config['MAIN']['work_dir'] if 'MAIN' in self.config and 'work_dir' in self.config['MAIN'] else None
return False if path is None or path == "":
if path.lower() == "none": print("No work directory specified, using default.")
print("WARNING: Work directory set to none in config.ini") path = self.create_work_dir()
return False return path
if not os.path.exists(path):
print(f"WARNING: Work directory {path} does not exist")
return False
return True
def config_exists(self): def config_exists(self):
"""Check if the config file exists.""" """Check if the config file exists."""
@@ -73,11 +69,10 @@ class Tools():
default_path = os.path.dirname(os.getcwd()) default_path = os.path.dirname(os.getcwd())
if self.config_exists(): if self.config_exists():
self.config.read('./config.ini') self.config.read('./config.ini')
config_path = self.config['MAIN']['work_dir'] or os.getenv('WORK_DIR') workdir_path = self.safe_get_work_dir_path()
dir_path = default_path if not self.check_config_dir_validity() else config_path
else: else:
dir_path = default_path workdir_path = default_path
return dir_path return workdir_path
@abstractmethod @abstractmethod
def execute(self, blocks:[str], safety:bool) -> str: def execute(self, blocks:[str], safety:bool) -> str: