# Use the official Python 3.12 slim image FROM python:3.12-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ git \ curl \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean # Create cache directories with proper permissions RUN mkdir -p /tmp/huggingface_cache /tmp/transformers_cache /tmp/datasets_cache && \ chmod -R 777 /tmp/huggingface_cache /tmp/transformers_cache /tmp/datasets_cache # Set environment variables for cache directories ENV HF_HOME=/tmp/huggingface_cache ENV TRANSFORMERS_CACHE=/tmp/transformers_cache ENV HF_DATASETS_CACHE=/tmp/datasets_cache ENV PYTHONUNBUFFERED=1 ENV PORT=7860 # Copy and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy all application files COPY . . # Expose the port EXPOSE 7860 # Run the FastAPI app with Uvicorn on port 7860 (required by HF Spaces) CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] # docker build -t precollegefastapi . # docker images # docker ps # docker run --env-file .env -p 8080:8080 precollegefastapi # docker tag precollegefastapi asura0575/precollegefastapi:latest # docker push asura0575/precollegefastapi