| # Use an official lightweight Python image as a parent image | |
| FROM python:3.9-slim | |
| # Set the working directory in the container to /code | |
| WORKDIR /code | |
| # Set the environment variable for the Hugging Face cache. | |
| ENV HF_HOME /code/cache | |
| ENV HUGGINGFACE_HUB_CACHE /code/cache | |
| # Create the cache directory and give it open permissions. | |
| RUN mkdir -p /code/cache && chmod 777 /code/cache | |
| # --- THIS IS THE FIX --- | |
| # Install git, which is required by pip to install packages from a git repository. | |
| # apt-get update refreshes the package list. | |
| # -y flag automatically confirms the installation. | |
| # --no-install-recommends keeps the image size small. | |
| RUN apt-get update && apt-get install -y git --no-install-recommends | |
| # Copy the requirements file into the container | |
| COPY ./requirements.txt /code/requirements.txt | |
| # Install packages | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Copy the rest of the application's code | |
| COPY ./app.py /code/app.py | |
| # Expose port 7860 | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |