plan291037 commited on
Commit
81d504c
·
verified ·
1 Parent(s): 446f0bb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -11
Dockerfile CHANGED
@@ -1,25 +1,36 @@
1
- # ใช้ Python base ปกติ + ติดตั้ง Playwright + Chromium ตอน build ให้เรียบร้อย
2
  FROM python:3.12-slim
3
 
4
- # พื้ฐาระ
5
- RUN apt-get update && apt-get install -y --no-install-recommends \
6
- ca-certificates wget gnupg \
7
- && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
8
 
9
  WORKDIR /app
10
 
11
- # ติดตั้งไลบรารีของแอป
12
  COPY requirements.txt ./
13
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
 
14
 
15
- # ติดตั้งเบรา์เซอร์สำรัPlaywright (รวsystem deps)
16
  RUN python -m playwright install --with-deps chromium
17
 
18
  # วางโค้ดแอป
19
  COPY app.py ./
20
 
21
- # พอ์ตมนขอHugging Face
22
- EXPOSE 7860
23
 
24
- # รันแอป
25
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Python base + ติดตั้ง Playwright + Chromium ตอน build
2
  FROM python:3.12-slim
3
 
4
+ # --- ENV สำคัญ: เปลี่ยตำแห่งเก็ browser และ HOME ให้เขียนได้ ---
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
7
+ HOME=/home/opener \
8
+ PORT=7860 \
9
+ HOST=0.0.0.0
10
+
11
+ # สร้าง user ปลอดภัย + โฟลเดอร์ที่ต้องใช้ แล้วให้สิทธิ์
12
+ RUN useradd -m -d /home/opener opener || true \
13
+ && apt-get update && apt-get install -y --no-install-recommends \
14
+ ca-certificates wget gnupg \
15
+ && rm -rf /var/lib/apt/lists/* \
16
+ && mkdir -p /ms-playwright /tmp/pw-opener-profile /app \
17
+ && chown -R opener:opener /ms-playwright /tmp/pw-opener-profile /app /home/opener
18
 
19
  WORKDIR /app
20
 
21
+ # ไลบรารีของแอป
22
  COPY requirements.txt ./
23
+ RUN pip install --upgrade pip \
24
+ && pip install --no-cache-dir -r requirements.txt
25
 
26
+ # ติดตั้ง Chromium ล่น้า (จะถูกเก็ใน /ms-playwright ตาENV)
27
  RUN python -m playwright install --with-deps chromium
28
 
29
  # วางโค้ดแอป
30
  COPY app.py ./
31
 
32
+ # รันด้วย user ที่เราง (เลี่ยงสิทธิ์ root และปัญหา /.cache)
33
+ USER opener
34
 
35
+ EXPOSE 7860
36
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]