# Use a base image with Python FROM python:3.10-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/* # Install Node.js (for serving frontend if needed) RUN apt-get install -y curl && \ curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ apt-get install -y nodejs # Copy and install Python dependencies COPY requirements.txt ./ RUN pip install --upgrade pip && pip install -r requirements.txt # Copy all files COPY . . # Set environment variable for Together API key (set via HF secrets) ENV TOGETHER_API_KEY=${TOGETHER_API_KEY} # Build React frontend RUN cd ./ && npm install && npm run build # Use uvicorn to launch FastAPI EXPOSE 7860 CMD ["uvicorn", "api_service:app", "--host", "0.0.0.0", "--port", "7860"]