# 使用基础镜像 FROM python:3.8-slim # 设置工作目录 WORKDIR /app # 复制应用程序代码到工作目录 #COPY . . # 添加Google的签名密钥 RUN apt update && apt install -y unzip wget gnupg && wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - # 添加Google Chrome的仓库 RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' # 更新软件包列表并安装Google Chrome RUN apt-get update && apt-get install -y google-chrome-stable \ && apt-get clean && rm -rf /var/lib/apt/lists/* RUN wget -O chromedriver.zip "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.62/linux64/chromedriver-linux64.zip" \ && unzip chromedriver.zip -d /usr/local/bin/ \ && mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/ \ && rm -rf /usr/local/bin/chromedriver-linux64 chromedriver.zip RUN chmod 777 /usr/local/bin/chromedriver COPY . . # 安装 Python 依赖项 RUN pip install --no-cache-dir -r requirements.txt # 暴露端口 EXPOSE 3000 # 启动应用程序 ENTRYPOINT ["python", "./main.py"]