# Use Node.js for the base as it's the main entry point FROM node:18-bullseye-slim # Install Python and build dependencies RUN apt-get update && apt-get install -y \ python3.10 \ python3-pip \ python3-dev \ libgl1-mesa-glx \ libgomp1 \ libsm6 \ libxext6 \ libxrender-dev \ curl \ && rm -rf /var/lib/apt/lists/* # Set python3 as the default python RUN ln -s /usr/bin/python3 /usr/bin/python WORKDIR /app # Copy package files COPY package.json package-lock.json ./ # Install Node dependencies RUN npm install --production # Copy python requirements COPY backend/src/python/requirements.txt ./python_requirements.txt # Install Python dependencies RUN pip install --no-cache-dir -r python_requirements.txt # Pre-download PaddleOCR models to cache them in the image RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(use_textline_orientation=True, lang='en')" # Copy all source code COPY . . # Set environment variables ENV NODE_ENV=production ENV PYTHON_OCR_URL=http://localhost:5001/ocr ENV PORT=7860 # Make start script executable RUN chmod +x start.sh # Hugging Face Spaces run on port 7860 EXPOSE 7860 # Start both servers CMD ["./start.sh"]