dragg2 commited on
Commit
0fbd8ff
·
verified ·
1 Parent(s): 965692e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -17
Dockerfile CHANGED
@@ -1,26 +1,27 @@
1
- # 步骤 1: 选择一个合适的 Python 基础镜像。python:3.11-slim 是一个稳定且轻量的选择。
2
- FROM python:3.11-slim
3
 
4
- # 步骤 2: 安装 git,以便我们可以从 GitHub 克隆代码。
5
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
6
 
7
- # 步骤 3: 设置容器内的工作目录。
8
  WORKDIR /app
9
 
10
- # 步骤 4: 克隆项目代码。关键在于使用 "-b light" 来指定克隆 "light" 分支。
11
- # 末尾的 "." 表示将代码克隆到当前工作目录 (/app) 内。
12
- RUN git clone -b light https://github.com/VeroFess/grok2api.git .
13
 
14
- # 步骤 5: 安装项目所需的 Python 依赖库。
15
- RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- # 步骤 6: (推荐) 预先设置整个应用目录的权限,避免任何潜在的权限问题。
18
- # 这是一个好习惯,可以防止应用因尝试写入日志或其他文件而被拒绝。
19
- RUN chmod -R 777 /app
20
 
21
- # 步骤 7: 暴露端口。根据 README 中的 docker-compose.yml 示例,我们知道应用在 8080 端口上运行。
22
- EXPOSE 8080
 
23
 
24
- # 步骤 8: 设置容器启动命令。
25
- # README 中的 docker-compose.yml 文件明确指出使用 uvicorn 启动,这是在容器中运行 FastAPI 应用的标准方式。
26
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
 
 
 
1
+ FROM mcr.microsoft.com/playwright/python:v1.44.0-jammy
 
2
 
3
+ # 安装git
4
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
5
 
6
+ # 设置工作目录
7
  WORKDIR /app
8
 
9
+ # 在工作目录中,从GitHub克隆项目代码
10
+ # 注意后面的 ".",它表示将代码克隆到当前目录 (/app) 而不是创建新目录
11
+ RUN git clone https://github.com/VeroFess/grok2api.git .
12
 
13
+ # 安装Python依赖
14
+ RUN pip install --no-cache-dir flask requests curl_cffi werkzeug loguru python-dotenv playwright gunicorn
15
 
16
+ # 安装Playwright浏览器依赖
17
+ RUN python -m playwright install --with-deps chrome
 
18
 
19
+ # 设置Hugging Face要求的端口
20
+ ENV PORT=7860
21
+ ENV PYTHONUNBUFFERED=1
22
 
23
+ # 暴露端口
24
+ EXPOSE 7860
25
+
26
+ # 启动应用的命令,确保端口是7860
27
+ CMD ["bash", "-lc", "gunicorn wsgi:app --bind 0.0.0.0:${PORT:-7860} --workers ${WORKERS:-1} --threads ${THREADS:-8} --worker-class gthread --timeout ${TIMEOUT:-180}"]