FROM python:3.9-slim WORKDIR /app # Create user-writable cache and temp directories ENV HF_HOME=/app/.cache ENV TORCH_HOME=/app/.cache/torch ENV TMPDIR=/app/tmp RUN mkdir -p /app/.cache/huggingface /app/.cache/torch /app/tmp RUN chmod -R 777 /app/.cache /app/tmp # Copy requirements first for better caching COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application COPY app/ ./app/ # Create required directories with proper permissions RUN mkdir -p uploads models RUN chmod -R 777 uploads models # Set environment variables ENV PYTHONPATH=/app ENV PORT=7860 ENV PYTHONUNBUFFERED=1 # Expose the port EXPOSE 7860 # Start the application CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]