ASC8384 commited on
Commit
4c7be44
·
1 Parent(s): 1e09d08
Files changed (1) hide show
  1. Dockerfile +13 -24
Dockerfile CHANGED
@@ -54,34 +54,23 @@ RUN apt-get update && apt-get install -y \
54
 
55
  WORKDIR /app
56
 
57
- # 复制requirements文件
58
- COPY requirements.txt .
59
-
60
- # 安装Python依赖
61
- RUN pip install --no-cache-dir -r requirements.txt
62
 
63
- # 设置环境变量(与我们的init_playwright.py脚本配合)
64
- ENV PLAYWRIGHT_BROWSERS_PATH=/app/.cache/ms-playwright
65
- ENV PLAYWRIGHT_SKIP_BROWSER_GC=1
66
- ENV XDG_CACHE_HOME=/app/.cache
67
- ENV HOME=/app
68
- ENV TMPDIR=/app/.cache/tmp
69
- ENV TMP=/app/.cache/tmp
70
- ENV TEMP=/app/.cache/tmp
71
-
72
- # 创建缓存目录并设置权限
73
- RUN mkdir -p /app/.cache/ms-playwright /app/.cache/tmp && \
74
- chmod -R 755 /app/.cache
75
 
76
- # 安装playwright浏览器到指定目录
77
- RUN playwright install chromium --with-deps || \
78
- (echo "第一次安装失败,尝试不使用--with-deps" && playwright install chromium)
79
 
80
- # 复制应用代码
81
- COPY . .
 
 
82
 
83
- # 确保所有文件有正确权限
84
- RUN chmod +x init_playwright.py
85
 
86
  # 暴露端口
87
  EXPOSE 7860
 
54
 
55
  WORKDIR /app
56
 
 
 
 
 
 
57
 
58
+ # RUN pip install --no-cache-dir -r requirements.txt
59
+ # Install Python dependencies
60
+ RUN pip install --upgrade pip
61
+ COPY requirements.txt .
62
+ RUN pip install -r requirements.txt
 
 
 
 
 
 
 
63
 
64
+ # Install Playwright and download the required browsers
65
+ RUN playwright install --with-deps
 
66
 
67
+ # Create and switch to a non-root user
68
+ RUN useradd -m -u 1000 user
69
+ USER user
70
+ ENV PATH="/home/user/.local/bin:$PATH"
71
 
72
+ # Ensure Playwright browsers are installed for the non-root user
73
+ RUN playwright install
74
 
75
  # 暴露端口
76
  EXPOSE 7860