# Base SageMath Image (Ubuntu) FROM sagemath/sagemath:latest USER root # 1. Install Node.js, npm, Python dependencies, and build tools natively RUN apt-get update && apt-get install -y \ curl gnupg python3-pip python3-venv nodejs npm build-essential \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # 2. Setup Python environment COPY requirements.txt . RUN python3 -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" RUN pip install --no-cache-dir -r requirements.txt # 3. Setup Node.js app COPY package.json ./ RUN npm install # 4. Copy source files COPY . . # 5. Boot Script (Starts Local Python AI in background, Node.js in foreground) RUN echo '#!/bin/bash\n\ uvicorn local_ai_server:app --host 127.0.0.1 --port 8000 & \n\ sleep 5 \n\ node server.js\n' > start.sh && chmod +x start.sh EXPOSE 7860 # 6. Execute boot script CMD ["./start.sh"]