Spaces:
Sleeping
Sleeping
File size: 1,057 Bytes
ba2fc46 534a729 370480b 534a729 370480b 534a729 370480b 534a729 370480b 3f23aac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# Dockerfile for Python FastAPI Application
# 1. Base Image
FROM python:3.11-slim
# 2. Set Environment Variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# 3. Install System Dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
pkg-config \
python3-dev \
gcc \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# 4. Set Work Directory
WORKDIR /app
# 5. Install Dependencies (Layer Caching Strategy)
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt --default-timeout 1000 \
--extra-index-url https://download.pytorch.org/whl/cpu
# 6. Copy Application Code
COPY . .
# --- 🔥 FIX: PYTHONPATH ADDED 🔥 ---
# Ye Python ko batata hai ke 'backend' folder root mein hai
ENV PYTHONPATH=/app:$PYTHONPATH
# 7. Expose Port
EXPOSE 8000
# 8. Run Command (Universal Logic)
# Yeh check karega: Agar server ne PORT diya hai to wo use karo, warna 8000 use karo.
CMD uvicorn backend.src.main:app --host 0.0.0.0 --port ${PORT:-8000}
|