# Use an official Python runtime as a parent image FROM python:3.12-slim-bookworm # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Ensure HF_TOKEN is picked up from the environment # ENV HF_TOKEN=${HUGGINGFACE_TOKEN} # Set work directory in the container WORKDIR /code # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ default-libmysqlclient-dev \ && rm -rf /var/lib/apt/lists/* # Create the cache directory RUN mkdir -p /models/cache # Ensure the directory is writable RUN chmod -R 777 /models/cache # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the current directory contents into the container at /code COPY ./api /code/api # Run the command to start uWSGI # Run Huggingface CLI login during runtime CMD ["sh", "-c", "gunicorn -b 0.0.0.0:7860 api.app:app"]