Spaces:
Sleeping
Sleeping
| # Use an official Python runtime as a parent image | |
| FROM python:3.10-slim | |
| # Set the working directory | |
| WORKDIR /code | |
| # Copy requirements and install | |
| COPY requirements.txt . | |
| # --- NEW CONSOLIDATED BLOCK --- | |
| # We will do everything in one layer to avoid caching issues. | |
| RUN \ | |
| # 0. Install system dependencies for OpenCV (libgl1 and libglib2.0-0) | |
| echo "--- INSTALLING SYSTEM DEPS (libgl1, libglib2.0-0) ---" && \ | |
| apt-get update && apt-get install -y libgl1 libglib2.0-0 && \ | |
| echo "----------------------------------------------------" && \ | |
| \ | |
| # 1. Print the contents of requirements.txt to be sure | |
| echo "--- CONTENTS OF requirements.txt ---" && \ | |
| cat requirements.txt && \ | |
| echo "----------------------------------" && \ | |
| \ | |
| # 2. Install the packages | |
| echo "--- INSTALLING PACKAGES ---" && \ | |
| python3 -m pip install --no-cache-dir -r requirements.txt && \ | |
| \ | |
| # 3. Print the list of installed packages | |
| echo "--- PIP LIST AFTER INSTALL ---" && \ | |
| python3 -m pip list && \ | |
| echo "----------------------------" && \ | |
| \ | |
| # 4. Pre-download the models | |
| echo "--- PRE-DOWNLOADING MODELS ---" && \ | |
| python3 -c "from fastanpr import FastANPR; FastANPR()" && \ | |
| echo "--- MODEL PRE-DOWNLOAD SUCCESSFUL ---" | |
| # Copy your main application file | |
| COPY api.py . | |
| # Command to run the application | |
| CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"] | |