# We use a base image that has Python installed FROM python:3.9-slim # Install Node.js (for the website) and system tools RUN apt-get update && apt-get install -y curl build-essential && \ curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ apt-get install -y nodejs && \ rm -rf /var/lib/apt/lists/* WORKDIR /app # 1. Install Python Dependencies (The AI Brain) # We install these libraries to talk to the GPU RUN pip install flask flask-cors torch diffusers transformers accelerate sentencepiece protobuf --extra-index-url https://download.pytorch.org/whl/cu118 # 2. Install Node Dependencies (The Website) COPY package*.json ./ RUN npm install # 3. Copy Code COPY . . # 4. OPTIMIZATION: Set cache to persistent storage [Cite: 7] ENV HF_HOME=/data/.huggingface # 5. Build Website RUN npm run build # 6. Open Port EXPOSE 7860 # 7. Start both servers CMD ["sh", "-c", "python3 ai_server.py & npm start -- -p 7860"]