98 lines
2.9 KiB
Docker
98 lines
2.9 KiB
Docker
FROM --platform=linux/amd64 ubuntu:22.04
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
WORKDIR /app
|
|
|
|
# Install essential packages and Chrome dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
wget \
|
|
unzip \
|
|
curl \
|
|
gnupg \
|
|
python3-dev \
|
|
python3-pip \
|
|
python3-wheel \
|
|
build-essential \
|
|
fonts-liberation \
|
|
libasound-dev \
|
|
libasound2 \
|
|
portaudio19-dev \
|
|
libatk-bridge2.0-0 \
|
|
libdrm2 \
|
|
libxcomposite1 \
|
|
libxdamage1 \
|
|
libfontconfig1 \
|
|
libxrandr2 \
|
|
libgbm1 \
|
|
libxss1 \
|
|
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/*
|
|
|
|
RUN pip3 install --upgrade pip setuptools wheel && \
|
|
pip3 install selenium
|
|
|
|
# Install dependencies
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY api.py .
|
|
# Chrome bundle approach, commented out opting for direct download
|
|
#COPY chrome_bundle/ ./chrome_bundle/
|
|
COPY sources/ ./sources/
|
|
COPY prompts/ ./prompts/
|
|
COPY crx/ crx/
|
|
COPY llm_router/ llm_router/
|
|
RUN ls
|
|
COPY .env.example .env
|
|
|
|
# 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 && \
|
|
# wget -O chromedriver-linux64.zip https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chromedriver-linux64.zip && \
|
|
# unzip chrome-headless-shell-linux64.zip && \
|
|
# unzip chromedriver-linux64.zip && \
|
|
# mkdir -p /opt/google && \
|
|
# ls -la && \
|
|
# mv chrome-headless-shell-linux64 /opt/google/chrome && \
|
|
# mv chromedriver-linux64/chromedriver /usr/local/bin/chromedriver && \
|
|
# chmod +x /opt/google/chrome/chrome-headless-shell && \
|
|
# chmod +x /usr/local/bin/chromedriver
|
|
|
|
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 && \
|
|
apt-get update && \
|
|
apt-get install -y google-chrome-stable && \
|
|
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
|
|
|
|
ENV DISPLAY=:99
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Run the application
|
|
CMD ["python3", "api.py"] |