Spaces:
Sleeping
Sleeping
| # Use Python 3.12.3 as base image | |
| FROM python:3.12.3-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Set environment variables | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements and install Python dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy project files | |
| COPY main_api.py . | |
| COPY interface.py . | |
| # Copy any other necessary files | |
| COPY . . | |
| # Note: Remove .env copy for HF Spaces - use HF Spaces secrets instead | |
| # COPY .env . | |
| # Expose port 7860 (required by Hugging Face Spaces) | |
| EXPOSE 7860 | |
| # Create entry point script for HF Spaces | |
| RUN echo '#!/bin/bash\n\ | |
| echo "Starting FastAPI server..."\n\ | |
| python main_api.py &\n\ | |
| echo "Waiting for FastAPI to start..."\n\ | |
| sleep 10\n\ | |
| echo "Starting Gradio interface..."\n\ | |
| python interface.py\n\ | |
| wait\n' > /app/entrypoint.sh && \ | |
| chmod +x /app/entrypoint.sh | |
| # Run both services | |
| CMD ["/app/entrypoint.sh"] |