atharvawarade9807 commited on
Commit
ac9f12f
·
verified ·
1 Parent(s): 27549a7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -29
Dockerfile CHANGED
@@ -1,22 +1,12 @@
1
  # =====================================================================
2
- # 1. LINUX ENGINE & ENVIRONMENT CONFIGURATION
3
  # =====================================================================
4
  FROM python:3.10-slim
5
 
6
  ENV PYTHONDONTWRITEBYTECODE=1
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 \
@@ -36,35 +26,51 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
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* ./
46
 
47
- RUN pip install --no-cache-dir --upgrade pip && \
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"]
 
 
1
  # =====================================================================
2
+ # 1. SYSTEM LAYER (Executed safely as Root)
3
  # =====================================================================
4
  FROM python:3.10-slim
5
 
6
  ENV PYTHONDONTWRITEBYTECODE=1
7
  ENV PYTHONUNBUFFERED=1
 
 
 
 
 
 
 
 
8
 
9
+ # Install bare-metal system libraries required by Chromium
 
 
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
  curl \
12
  git \
 
26
  libpango-1.0-0 \
27
  libcairo2 \
28
  libasound2 \
29
+ libxshmfence1 \
30
+ ca-certificates \
31
  && rm -rf /var/lib/apt/lists/*
32
 
33
+ # Create the Hugging Face user profile
34
+ RUN useradd -m -u 1000 user
35
+
36
+ # Create empty target directories and give ownership to the user immediately
37
+ RUN mkdir -p /home/user/app /home/user/venv && \
38
+ chown -R user:user /home/user
39
+
40
  # =====================================================================
41
+ # 2. USER SANDBOX LAYER (Safe from Hugging Face Permission Blocks)
42
  # =====================================================================
43
+ USER user
44
+ WORKDIR /home/user/app
45
 
46
+ # Instantiate and force the Virtual Environment to be the primary system path
47
+ RUN python -m venv /home/user/venv
48
+ ENV PATH="/home/user/venv/bin:$PATH"
49
+ ENV PYTHONPATH=/home/user/app
50
+ ENV PLAYWRIGHT_BROWSERS_PATH=/home/user/venv/ms-playwright
51
 
52
+ # Upgrade pip inside our isolated sandbox space
53
+ RUN pip install --no-cache-dir --upgrade pip
 
54
 
55
  # =====================================================================
56
+ # 3. DEPENDENCY & CODE INGESTION
57
  # =====================================================================
58
+ # 🔥 FIXED: Copy requirements.txt directly from the repository root workspace
59
+ COPY --chown=user:user requirements.txt ./
60
 
61
+ RUN pip install --no-cache-dir -r requirements.txt
62
+
63
+ # Install Playwright and the Chromium binaries entirely within user space
64
+ RUN pip install --no-cache-dir playwright && \
65
+ playwright install chromium
66
+
67
+ # Bring in the rest of your app files under native user ownership
68
+ COPY --chown=user:user . .
69
 
 
70
  EXPOSE 7860
71
 
72
  # =====================================================================
73
+ # 4. RUNTIME EXECUTION
74
  # =====================================================================
75
+ # 🔥 FIXED: Targeted directly to main:app since main.py sits at repository root level
76
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]