| # Sử dụng Python 3.10 slim làm base image | |
| FROM python:3.10-slim | |
| # Thiết lập thư mục làm việc | |
| WORKDIR /app | |
| # Cài đặt các gói hệ thống cần thiết | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| gcc \ | |
| python3-dev \ | |
| libpq-dev \ | |
| git \ | |
| libgl1-mesa-glx \ | |
| libglib2.0-0 \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Sao chép và cài đặt các thư viện từ requirements.txt | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Sao chép toàn bộ mã nguồn ứng dụng vào container | |
| COPY . . | |
| # Mở port 8000 | |
| EXPOSE 8000 | |
| # Chạy ứng dụng FastAPI bằng Uvicorn | |
| CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"] | |