Spaces:
Sleeping
Sleeping
File size: 1,092 Bytes
ee16852 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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"] |