FROM python:3.9-slim # Install Node.js for frontend build RUN apt-get update && apt-get install -y curl && \ curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ apt-get install -y nodejs && \ rm -rf /var/lib/apt/lists/* # Hugging Face Spaces require running as a non-root user with ID 1000 RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app # Copy requirements and install Python deps COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy frontend source and build COPY --chown=user frontend/ ./frontend/ RUN cd frontend && npm install && npm run build # Copy backend source COPY --chown=user backend/ ./backend/ COPY --chown=user codeblue_context.py . # Copy built frontend to backend static directory RUN rm -rf backend/static && mkdir -p backend/static && cp -r frontend/dist/* backend/static/ # Set environment variables for Hugging Face ENV PORT=7860 ENV HOST=0.0.0.0 EXPOSE 7860 # Run FastAPI server CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]