atharvawarade9807 commited on
Commit
facd945
·
verified ·
1 Parent(s): 5739965

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -45
Dockerfile CHANGED
@@ -1,55 +1,53 @@
1
- # Start from a clean, optimized Python runtime environment
 
 
2
  FROM python:3.10-slim
3
 
4
- # Set systemic environment variables to streamline Python container executions
5
  ENV PYTHONDONTWRITEBYTECODE=1
6
  ENV PYTHONUNBUFFERED=1
7
- ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
8
 
9
- # Establish workspace directory context inside the virtual container filesystem
10
- WORKDIR /code
 
11
 
12
- # Install system utilities and native C-libraries essential for Headless Chromium / Playwright execution
 
 
 
 
 
 
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  build-essential \
15
- libnss3 \
16
- libnspr4 \
17
- libatk1.0-0 \
18
- libatk-bridge2.0-0 \
19
- libcups2 \
20
- libdrm2 \
21
- libxkbcommon0 \
22
- libxcomposite1 \
23
- libxdamage1 \
24
- libxfixes3 \
25
- libxrandr2 \
26
- libgbm1 \
27
- libasound2 \
28
- wget \
29
- gnupg \
30
  && rm -rf /var/lib/apt/lists/*
31
 
32
- # Cache requirements mapping layer independently to optimize subsequent container rebuild timelines
33
- COPY ./requirements.txt /code/requirements.txt
34
-
35
- # Execute installation of Python dependencies and runtime packages
36
- # --no-cache-dir ensures massive deep-learning framework wheels aren't saved in the image layer
37
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
38
-
39
- # Systematically download and provision isolated Chromium drivers into the target path environment
40
- RUN playwright install chromium --with-deps
41
-
42
- # Copy the remaining application project directories, codebases, and your manually uploaded models
43
- # directly into the container workspace
44
- COPY . .
45
-
46
- # Adjust filesystem read/write privileges explicitly to align with Hugging Face runtime space requirements
47
- RUN chmod -R 777 /code
48
-
49
- # Expose standard networking communication port (Hugging Face standard)
50
- EXPOSE 7860
51
-
52
- # Bind startup command sequence to execute the root Master Gateway router directly.
53
- # NOTE: Adjusted to 'Server.main:app' based on your Python scripts. If your main.py is
54
- # strictly in the root directory, change this back to 'main:app'.
55
- CMD ["uvicorn", "Server.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
1
+ # =====================================================================
2
+ # 1. BASE RUNTIME SETUP
3
+ # =====================================================================
4
  FROM python:3.10-slim
5
 
6
+ # Prevent Python from writing .pyc files and buffer streams for real-time logs
7
  ENV PYTHONDONTWRITEBYTECODE=1
8
  ENV PYTHONUNBUFFERED=1
 
9
 
10
+ # 🔥 THE PERMANENT FIX: Force the container to include the root workspace
11
+ # in Python's search path so 'Server' is globally discoverable as a module.
12
+ ENV PYTHONPATH=/app
13
 
14
+ # Establish the core execution workspace
15
+ WORKDIR /app
16
+
17
+ # =====================================================================
18
+ # 2. SYSTEM DEPENDENCIES & LINUX LIBRARIES
19
+ # =====================================================================
20
+ # Install essential compilation tools and library components
21
  RUN apt-get update && apt-get install -y --no-install-recommends \
22
  build-essential \
23
+ curl \
24
+ git \
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  && rm -rf /var/lib/apt/lists/*
26
 
27
+ # =====================================================================
28
+ # 3. DEPENDENCY INSTALLATION (CACHED LAYER)
29
+ # =====================================================================
30
+ # Copy requirements first to leverage Docker's layer caching architecture
31
+ COPY Server/requirements.txt /app/Server/requirements.txt
32
+
33
+ RUN pip install --no-cache-dir --upgrade pip && \
34
+ pip install --no-cache-dir -r /app/Server/requirements.txt
35
+
36
+ # 🛠️ PLAYWRIGHT LINUX SUBSYSTEM MATCH: Install Chromium and its Linux dependencies
37
+ # This ensures Engine 6's interactive sandbox doesn't crash on system missing (.so) links
38
+ RUN playwright install --with-deps chromium
39
+
40
+ # =====================================================================
41
+ # 4. APPLICATION SOURCE DEPLOYMENT
42
+ # =====================================================================
43
+ # Copy the entire workspace tree into the container (preserves Version_2-Copy, etc.)
44
+ COPY . /app
45
+
46
+ # Expose the master gateway network port
47
+ EXPOSE 8000
48
+
49
+ # =====================================================================
50
+ # 5. SECURE RUNTIME EXECUTION
51
+ # =====================================================================
52
+ # Execute from the root context, completely safe under the injected PYTHONPATH
53
+ CMD ["uvicorn", "Server.main:app", "--host", "0.0.0.0", "--port", "8000"]