akash-api / Dockerfile
hzruo's picture
Update Dockerfile
f229f74 verified
raw
history blame
2.31 kB
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
libcurl4-openssl-dev \
libssl-dev \
# Chrome dependencies
wget \
gnupg \
fonts-liberation \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxkbcommon0 \
libxrandr2 \
xdg-utils \
# Install Chrome
&& wget -q -O - https://dl-ssl.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.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 配置 DrissionPage
RUN cd /usr/local/lib/python3.11/site-packages/DrissionPage/_configs/ && \
sed -i "/browser_path/s/$(grep 'browser_path' 'configs.ini' | awk -F '=' '{print $2}')/\/usr\/bin\/google-chrome-stable/" configs.ini && \
sed -i "/arguments/s/\[/\[\'--no-sandbox\', \'--headless=new\', \'--disable-dev-shm-usage\', \'--disable-gpu\', \'--disable-software-rasterizer\', \'--disable-extensions\', \'--disable-setuid-sandbox\', \'--no-first-run\', \'--no-zygote\', \'--single-process\', \'--remote-debugging-port=9222\', \'--window-size=1920,1080\', \'--user-agent=Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/120.0.0.0 Safari\/537.36\', \'--enable-logging\', \'--v=1\', \'--remote-debugging-address=127.0.0.1\', /" configs.ini
# Copy the rest of the application
COPY . .
# 创建并设置 Chrome 数据目录
RUN mkdir -p /tmp/chrome-data && chmod 777 /tmp/chrome-data
# Expose the port the app runs on
EXPOSE 7860
# Environment variables with defaults
ENV OPENAI_API_KEY=None
ENV ENVIRONMENT="production"
ENV PORT=7860
ENV CHROME_PATH=/usr/bin/google-chrome-stable
ENV CHROME_USER_DATA_DIR=/tmp/chrome-data
# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]