2025-05-11 23:06:57 +08:00

35 lines
1.3 KiB
Plaintext

# Dockerfile for cursor-auto-register
# 1. 选择 Python 基础镜像
FROM python:3.10-slim
# 2. 设置环境变量,防止 Python 缓冲输出
ENV PYTHONUNBUFFERED=1
# 3. 设置工作目录
WORKDIR /app
# 4. 复制依赖文件
COPY requirements.txt .
# 5. 安装系统依赖 (针对 Playwright) 和 Python 依赖
# 更新 apt 包列表,安装 Playwright 所需的依赖,然后安装 Python 包,最后清理 apt 缓存
RUN apt-get update && \
apt-get install -y --no-install-recommends libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2 && \
pip install --no-cache-dir -r requirements.txt && \
# 下载 Playwright 浏览器 (chromium, firefox, webkit 可按需选择)
playwright install --with-deps chromium && \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
rm -rf /var/lib/apt/lists/*
# 6. 复制项目代码到工作目录
COPY . .
# 7. 暴露应用程序端口 (根据 .env 文件配置,默认为 8000)
EXPOSE 8000
# 8. 定义容器启动时运行的命令
# 使用 uvicorn 启动 FastAPI 应用
# 确保 api.py 中 FastAPI app 实例的变量名为 'app'
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]