rkihacker commited on
Commit
c96f450
·
verified ·
1 Parent(s): 661476b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -30
Dockerfile CHANGED
@@ -1,40 +1,20 @@
1
- # =============================================
2
- # Stage 1: Builder
3
- # =============================================
4
- FROM python:3.11-slim AS builder
5
 
 
6
  WORKDIR /app
7
 
8
- # Install build dependencies
9
- RUN apt-get update && apt-get install -y --no-install-recommends \
10
- gcc \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Copy and install Python deps
14
  COPY requirements.txt .
15
- RUN pip install --no-cache-dir --user -r requirements.txt
16
-
17
- # =============================================
18
- # Stage 2: Final Runtime
19
- # =============================================
20
- FROM python:3.11-slim
21
 
22
- WORKDIR /app
 
23
 
24
- # Copy installed packages from builder
25
- COPY --from=builder /root/.local /root/.local
26
- ENV PATH=/root/.local/bin:$PATH
27
-
28
- # Copy app
29
  COPY main.py .
30
 
31
- # Enable unbuffered output
32
- ENV PYTHONUNBUFFERED=1
33
-
34
- # Expose FastAPI port
35
  EXPOSE 8000
36
 
37
- # =============================================
38
- # Auto-detect CPU cores and set Uvicorn workers
39
- # =============================================
40
- CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8000 --workers $(( $(nproc) * 2 ))"]
 
1
+ # Use official Python image
2
+ FROM python:3.9-slim
 
 
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
+ # Copy requirements first to leverage Docker cache
 
 
 
 
 
8
  COPY requirements.txt .
 
 
 
 
 
 
9
 
10
+ # Install dependencies
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Copy application code
 
 
 
 
14
  COPY main.py .
15
 
16
+ # Expose the port
 
 
 
17
  EXPOSE 8000
18
 
19
+ # Run the application
20
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]