url2txt / Dockerfile
qiqi657s's picture
Create Dockerfile
0c95d3e verified
# 使用官方 Python 3.10 镜像作为基础镜像
FROM python:3.10-slim
# 设置工作目录
WORKDIR /app
# 将当前目录的内容复制到容器中的 /app 目录
COPY . /app
# 安装系统依赖,特别是 Chrome 所需的图形和显示库
RUN apt-get update && \
apt-get install -y \
wget \
curl \
unzip \
libx11-dev \
libx11-xcb1 \
libxcb1 \
libgdk-pixbuf2.0-0 \
libnss3 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libdrm2 \
libdbus-1-3 \
libgbm1 \
libnspr4 \
libxcomposite1 \
libxrandr2 \
libgtk-3-0 \
libasound2 \
libxss1 \
fonts-liberation \
libappindicator3-1 \
libu2f-udev \
xdg-utils \
libvulkan1 \
&& rm -rf /var/lib/apt/lists/*
# 下载并安装 Chrome 浏览器
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
dpkg -i google-chrome-stable_current_amd64.deb || apt-get install -fy && \
rm google-chrome-stable_current_amd64.deb
# 安装 Python 项目依赖
RUN pip install --no-cache-dir -r requirements.txt
# 暴露 FastAPI 默认端口
EXPOSE 8000
# 给启动脚本赋予执行权限
RUN chmod +x /app/init_chrome.sh
# 设定启动命令,启动 FastAPI 服务
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]