# Use a Python base image FROM python:3.9 # Create a non-root user for security best practices RUN useradd -m -u 1000 user USER user # Set environment variable for user's local bin path ENV PATH="/home/user/.local/bin:$PATH" # Set environment variables to prevent Python from buffering stdout/stderr ENV PYTHONUNBUFFERED 1 # IMPORTANT FIX: Set Hugging Face cache directory to a writable location ENV HF_HOME=/app/hf_cache # Set the working directory inside the container WORKDIR /app # Copy requirements.txt and install Python dependencies COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy the application file and other necessary files COPY --chown=user ./app.py /app/app.py # The cgpcorp_api_chat.py file is no longer needed as its logic is integrated into app.py # Removed: COPY --chown=user ./cgpcorp_api_chat.py /app/cgpcorp_api_chat.py COPY --chown=user ./README.md /app/README.md # Command to run the application using uvicorn EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]