feat : updating with latest docker backend build thx to #265
This commit is contained in:
+5
-3
@@ -1,7 +1,9 @@
|
|||||||
SEARXNG_BASE_URL="http://127.0.0.1:8080"
|
SEARXNG_BASE_URL="http://127.0.0.1:8080"
|
||||||
TOKENIZERS_PARALLELISM="false"
|
REDIS_BASE_URL="redis://redis:6379/0"
|
||||||
|
WORK_DIR_HOST="/Users/mlg/Documents/workspace_for_ai"
|
||||||
OPENAI_API_KEY='xxxxx'
|
OPENAI_API_KEY='xxxxx'
|
||||||
DEEPSEEK_API_KEY='xxxxx'
|
DEEPSEEK_API_KEY='xxxxx'
|
||||||
OPENROUTER_API_KEY='xxxxx'
|
OPENROUTER_API_KEY='xxxxx'
|
||||||
BACKEND_PORT=8000
|
TOGETHER_API_KEY='xxxx'
|
||||||
WORK_DIR="/tmp/"
|
GOOGLE_API_KEY='xxxxx'
|
||||||
|
ANTHROPIC_API_KEY='xxxxx'
|
||||||
+86
-57
@@ -1,67 +1,100 @@
|
|||||||
FROM --platform=linux/amd64 ubuntu:22.04
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
FROM --platform=linux/amd64 python:3.11-slim
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install essential packages and Chrome dependencies
|
# Install essential packages and Chrome dependencies
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update -y && apt-get install -y \
|
||||||
wget \
|
wget \
|
||||||
|
gnupg2 \
|
||||||
|
ca-certificates \
|
||||||
unzip \
|
unzip \
|
||||||
curl \
|
xvfb \
|
||||||
gnupg \
|
libxss1 \
|
||||||
python3-dev \
|
libappindicator1 \
|
||||||
python3-pip \
|
|
||||||
python3-wheel \
|
|
||||||
build-essential \
|
|
||||||
fonts-liberation \
|
fonts-liberation \
|
||||||
libasound-dev \
|
libnss3 \
|
||||||
libasound2 \
|
libatk1.0-0 \
|
||||||
portaudio19-dev \
|
|
||||||
libatk-bridge2.0-0 \
|
libatk-bridge2.0-0 \
|
||||||
|
libcups2 \
|
||||||
libdrm2 \
|
libdrm2 \
|
||||||
libxcomposite1 \
|
libxcomposite1 \
|
||||||
libxdamage1 \
|
libxdamage1 \
|
||||||
libfontconfig1 \
|
|
||||||
libxrandr2 \
|
libxrandr2 \
|
||||||
libgbm1 \
|
xdg-utils \
|
||||||
libxss1 \
|
dbus \
|
||||||
libnss3 \
|
|
||||||
libnspr4 \
|
|
||||||
libxshmfence1 \
|
|
||||||
libgconf-2-4 \
|
|
||||||
libxfixes3 \
|
|
||||||
libxinerama1 \
|
|
||||||
libgtk-3-0 \
|
|
||||||
libgdk-pixbuf2.0-0 \
|
|
||||||
libatspi2.0-0 \
|
|
||||||
libdrm2 \
|
|
||||||
libxkbcommon0 \
|
|
||||||
libepoxy0 \
|
|
||||||
libgtk-3-0 \
|
|
||||||
libharfbuzz0b \
|
|
||||||
libegl1-mesa \
|
|
||||||
libgles2-mesa \
|
|
||||||
# Virtual display for headless operation
|
|
||||||
xvfb \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN pip3 install --upgrade pip setuptools wheel && \
|
RUN apt-get update -y && \
|
||||||
pip3 install selenium
|
apt-get install -y \
|
||||||
|
gcc \
|
||||||
|
g++ \
|
||||||
|
gfortran \
|
||||||
|
libportaudio2 \
|
||||||
|
portaudio19-dev \
|
||||||
|
ffmpeg \
|
||||||
|
libavcodec-dev \
|
||||||
|
libavformat-dev \
|
||||||
|
libavutil-dev \
|
||||||
|
gnupg2 \
|
||||||
|
wget \
|
||||||
|
unzip \
|
||||||
|
python3 \
|
||||||
|
python3-pip \
|
||||||
|
libasound2 \
|
||||||
|
libatk-bridge2.0-0 \
|
||||||
|
libgtk-4-1 \
|
||||||
|
libnss3 \
|
||||||
|
xdg-utils \
|
||||||
|
wget \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
|
RUN apt-get update -y && \
|
||||||
|
apt-get install -y \
|
||||||
|
alsa-utils \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV CHROME_TESTING_VERSION=134.0.6998.88
|
||||||
|
ENV DISPLAY=:99
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
wget -qO /tmp/chrome.zip \
|
||||||
|
"https://storage.googleapis.com/chrome-for-testing-public/${CHROME_TESTING_VERSION}/linux64/chrome-linux64.zip"; \
|
||||||
|
unzip -q /tmp/chrome.zip -d /opt; \
|
||||||
|
rm /tmp/chrome.zip; \
|
||||||
|
ln -s /opt/chrome-linux64/chrome /usr/local/bin/google-chrome; \
|
||||||
|
ln -s /opt/chrome-linux64/chrome /usr/local/bin/chrome; \
|
||||||
|
mkdir -p /opt/chrome; \
|
||||||
|
ln -s /opt/chrome-linux64/chrome /opt/chrome/chrome; \
|
||||||
|
google-chrome --version
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
wget -qO /tmp/chromedriver.zip \
|
||||||
|
"https://storage.googleapis.com/chrome-for-testing-public/${CHROME_TESTING_VERSION}/linux64/chromedriver-linux64.zip"; \
|
||||||
|
unzip -q /tmp/chromedriver.zip -d /tmp; \
|
||||||
|
mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin; \
|
||||||
|
rm /tmp/chromedriver.zip; \
|
||||||
|
chmod +x /usr/local/bin/chromedriver; \
|
||||||
|
chromedriver --version
|
||||||
|
|
||||||
|
RUN chmod +x /opt/chrome/chrome
|
||||||
|
|
||||||
|
RUN pip3 install --upgrade pip setuptools wheel
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
RUN mkdir -p /opt/workspace
|
||||||
|
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY api.py .
|
COPY api.py .
|
||||||
# Chrome bundle approach, commented out opting for direct download
|
|
||||||
#COPY chrome_bundle/ ./chrome_bundle/
|
|
||||||
COPY sources/ ./sources/
|
COPY sources/ ./sources/
|
||||||
COPY prompts/ ./prompts/
|
COPY prompts/ ./prompts/
|
||||||
COPY crx/ crx/
|
COPY crx/ crx/
|
||||||
COPY llm_router/ llm_router/
|
COPY llm_router/ llm_router/
|
||||||
RUN ls
|
COPY config.ini .
|
||||||
COPY .env.example .env
|
|
||||||
|
|
||||||
# Install Chrome and ChromeDriver from chrome-for-testing
|
# Install Chrome and ChromeDriver from chrome-for-testing
|
||||||
#RUN wget -O chrome-headless-shell-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chrome-headless-shell-linux64.zip && \
|
#RUN wget -O chrome-headless-shell-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chrome-headless-shell-linux64.zip && \
|
||||||
@@ -75,24 +108,20 @@ COPY .env.example .env
|
|||||||
# chmod +x /opt/google/chrome/chrome-headless-shell && \
|
# chmod +x /opt/google/chrome/chrome-headless-shell && \
|
||||||
# chmod +x /usr/local/bin/chromedriver
|
# chmod +x /usr/local/bin/chromedriver
|
||||||
|
|
||||||
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
|
#RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
|
||||||
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
|
# echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
|
||||||
apt-get update && \
|
# apt-get update && \
|
||||||
apt-get install -y google-chrome-stable && \
|
# apt-get install -y google-chrome-stable && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
# rm -rf /var/lib/apt/lists/*
|
||||||
|
#
|
||||||
|
## Install matching ChromeDriver
|
||||||
|
#RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') && \
|
||||||
|
# wget -O chromedriver.zip "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION%%.*}/chromedriver_linux64.zip" && \
|
||||||
|
# unzip chromedriver.zip && \
|
||||||
|
# mv chromedriver /usr/local/bin/ && \
|
||||||
|
# chmod +x /usr/local/bin/chromedriver && \
|
||||||
|
# rm chromedriver.zip
|
||||||
|
|
||||||
# Install matching ChromeDriver
|
|
||||||
RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+') && \
|
|
||||||
wget -O chromedriver.zip "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION%%.*}/chromedriver_linux64.zip" && \
|
|
||||||
unzip chromedriver.zip && \
|
|
||||||
mv chromedriver /usr/local/bin/ && \
|
|
||||||
chmod +x /usr/local/bin/chromedriver && \
|
|
||||||
rm chromedriver.zip
|
|
||||||
|
|
||||||
ENV DISPLAY=:99
|
|
||||||
|
|
||||||
# Expose port
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
CMD ["python3", "api.py"]
|
CMD ["python3", "api.py"]
|
||||||
@@ -38,7 +38,7 @@ config.read('config.ini')
|
|||||||
|
|
||||||
api.add_middleware(
|
api.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=["http://localhost", "http://localhost:3000"],
|
allow_origins=["*"],
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=["*"],
|
allow_methods=["*"],
|
||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
|
|||||||
+10
-3
@@ -79,11 +79,18 @@ services:
|
|||||||
- ${BACKEND_PORT:-8000}:${BACKEND_PORT:-8000}
|
- ${BACKEND_PORT:-8000}:${BACKEND_PORT:-8000}
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/app
|
- ./:/app
|
||||||
- ${WORK_DIR}:${WORK_DIR}
|
- ${WORK_DIR_HOST:-.}:/opt/workspace
|
||||||
command: python3 api.py
|
command: python3 api.py
|
||||||
environment:
|
environment:
|
||||||
- SEARXNG_URL=http://localhost:8080
|
- SEARXNG_URL=${SEARXNG_BASE_URL:-http://searxng:8080}
|
||||||
- WORK_DIR=${WORK_DIR}
|
- REDIS_URL=${REDIS_BASE_URL:-redis://redis:6379/0}
|
||||||
|
- WORK_DIR_HOST=${WORK_DIR_HOST:-.}
|
||||||
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||||
|
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}
|
||||||
|
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY}
|
||||||
|
- TOGETHER_API_KEY=${TOGETHER_API_KEY}
|
||||||
|
- GOOGLE_API_KEY=${GOOGLE_API_KEY}
|
||||||
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
+1
-1
@@ -143,7 +143,7 @@ def create_driver(headless=False, stealth_mode=True, crx_path="./crx/nopecha.crx
|
|||||||
user_data_dir = tempfile.mkdtemp()
|
user_data_dir = tempfile.mkdtemp()
|
||||||
user_agent = get_random_user_agent()
|
user_agent = get_random_user_agent()
|
||||||
width, height = (1920, 1080)
|
width, height = (1920, 1080)
|
||||||
chrome_options.add_argument(f"--user-data-dir={user_data_dir}")
|
#chrome_options.add_argument(f"--user-data-dir={user_data_dir}")
|
||||||
chrome_options.add_argument(f"--accept-lang={lang}-{lang.upper()},{lang};q=0.9")
|
chrome_options.add_argument(f"--accept-lang={lang}-{lang.upper()},{lang};q=0.9")
|
||||||
chrome_options.add_argument("--disable-extensions")
|
chrome_options.add_argument("--disable-extensions")
|
||||||
chrome_options.add_argument("--disable-background-timer-throttling")
|
chrome_options.add_argument("--disable-background-timer-throttling")
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ 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']
|
config_path = self.config['MAIN']['work_dir'] or os.getenv('WORK_DIR')
|
||||||
dir_path = default_path if not self.check_config_dir_validity() else config_path
|
dir_path = default_path if not self.check_config_dir_validity() else config_path
|
||||||
else:
|
else:
|
||||||
dir_path = default_path
|
dir_path = default_path
|
||||||
|
|||||||
Reference in New Issue
Block a user