atharvawarade9807 commited on
Commit
f9560ff
·
verified ·
1 Parent(s): ea8f716

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -14
Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
  # =====================================================================
2
- # 1. CORE OPERATING SYSTEM ENGINE
3
  # =====================================================================
4
  FROM python:3.10-slim
5
 
@@ -7,27 +7,39 @@ ENV PYTHONDONTWRITEBYTECODE=1
7
  ENV PYTHONUNBUFFERED=1
8
  ENV HOME=/home/user
9
  ENV PYTHONPATH=/home/user/app
10
- # Forces Playwright to store browser engines in the accessible user workspace
11
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/app/.cache/ms-playwright
12
 
13
- # Configure Hugging Face standard non-root user context
14
  RUN useradd -m -u 1000 user
15
  WORKDIR /home/user/app
16
 
17
  # =====================================================================
18
- # 2. SYSTEM DEPENDENCIES & PLAYWRIGHT SUB-SYSTEMS (Root Clearance)
19
  # =====================================================================
20
- # 🔥 THE FIX: apt-get update must run right alongside playwright install
21
- # so the Linux package manager can find the required browser libraries.
22
  RUN apt-get update && apt-get install -y --no-install-recommends \
23
  curl \
24
  git \
25
- && pip install --no-cache-dir playwright \
26
- && playwright install --with-deps chromium \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  && rm -rf /var/lib/apt/lists/*
28
 
29
  # =====================================================================
30
- # 3. PYTHON PACKAGES PIPELINE
31
  # =====================================================================
32
  COPY --chown=user:user Server/requirements.txt* ./Server/
33
  COPY --chown=user:user requirements.txt* ./
@@ -36,19 +48,23 @@ RUN pip install --no-cache-dir --upgrade pip && \
36
  if [ -f "Server/requirements.txt" ]; then pip install --no-cache-dir -r Server/requirements.txt; \
37
  else pip install --no-cache-dir -r requirements.txt; fi
38
 
 
 
 
 
39
  # =====================================================================
40
- # 4. CODE DEPLOYMENT & PERMISSION ALIGNMENT
41
  # =====================================================================
42
  COPY --chown=user:user . .
43
 
44
- # Grant full permission control to the execution user profile
45
- RUN chown -R user:user /home/user
 
46
 
47
- # Securely drop down to Hugging Face sandbox privileges
48
  USER user
49
  EXPOSE 7860
50
 
51
  # =====================================================================
52
- # 5. CONTAINER BOOT GATEWAY
53
  # =====================================================================
54
  CMD ["uvicorn", "Server.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # =====================================================================
2
+ # 1. LINUX ENGINE & ENVIRONMENT CONFIGURATION
3
  # =====================================================================
4
  FROM python:3.10-slim
5
 
 
7
  ENV PYTHONUNBUFFERED=1
8
  ENV HOME=/home/user
9
  ENV PYTHONPATH=/home/user/app
10
+ # Locks Playwright browser binaries completely inside the application scope
11
  ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/app/.cache/ms-playwright
12
 
13
+ # Pre-render Hugging Face user context
14
  RUN useradd -m -u 1000 user
15
  WORKDIR /home/user/app
16
 
17
  # =====================================================================
18
+ # 2. MANUAL CHROMIUM SYSTEM DEPENDENCIES (Bypasses Playwright Sudo Script)
19
  # =====================================================================
 
 
20
  RUN apt-get update && apt-get install -y --no-install-recommends \
21
  curl \
22
  git \
23
+ libglib2.0-0 \
24
+ libnss3 \
25
+ libatk1.0-0 \
26
+ libatk-bridge2.0-0 \
27
+ libcups2 \
28
+ libdrm2 \
29
+ libxkbcommon0 \
30
+ libxcomposite1 \
31
+ libxdamage1 \
32
+ libxext6 \
33
+ libxfixes3 \
34
+ libxrandr2 \
35
+ libgbm1 \
36
+ libpango-1.0-0 \
37
+ libcairo2 \
38
+ libasound2 \
39
  && rm -rf /var/lib/apt/lists/*
40
 
41
  # =====================================================================
42
+ # 3. PYTHON PACKAGES & PLAYWRIGHT BROWSER PIPELINE
43
  # =====================================================================
44
  COPY --chown=user:user Server/requirements.txt* ./Server/
45
  COPY --chown=user:user requirements.txt* ./
 
48
  if [ -f "Server/requirements.txt" ]; then pip install --no-cache-dir -r Server/requirements.txt; \
49
  else pip install --no-cache-dir -r requirements.txt; fi
50
 
51
+ # Clean installation of the browser package without script overrides
52
+ RUN pip install --no-cache-dir playwright && \
53
+ playwright install chromium
54
+
55
  # =====================================================================
56
+ # 4. CODE INGESTION & ISOLATED PERMISSION FIX
57
  # =====================================================================
58
  COPY --chown=user:user . .
59
 
60
+ # 🔥 THE CRITICAL ONE-SHOT FIX: Apply permissions ONLY to /app.
61
+ # Do not touch the global /home/user path to avoid sandbox blocks.
62
+ RUN chown -R user:user /home/user/app
63
 
 
64
  USER user
65
  EXPOSE 7860
66
 
67
  # =====================================================================
68
+ # 5. CORE SERVICE RUNTIME BOOT
69
  # =====================================================================
70
  CMD ["uvicorn", "Server.main:app", "--host", "0.0.0.0", "--port", "7860"]