malepati/custom_template_working
0
1FROM python:3.11-slim-bookworm2# Optimized build - batched pip installs to avoid OOM errors3 4# Install system dependencies (removed libreoffice to reduce size)5RUN apt-get update && apt-get install -y \6 nginx \7 curl \8 fontconfig \9 chromium \10 && rm -rf /var/lib/apt/lists/*11 12# Install Node.js 20 using NodeSource repository13RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \14 apt-get install -y nodejs && \15 rm -rf /var/lib/apt/lists/*16 17# Create a working directory18WORKDIR /app 19 20# Set environment variables21ENV APP_DATA_DIRECTORY=/app_data22ENV TEMP_DIRECTORY=/tmp/presenton23ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium24ENV PIP_NO_CACHE_DIR=125ENV PIP_DISABLE_PIP_VERSION_CHECK=126 27# Copy requirements first28COPY servers/fastapi/requirements.txt /app/servers/fastapi/requirements.txt29 30# Install pip requirements in batches to avoid OOM on Hugging Face31# Batch 1: Core async and database libraries32RUN pip install --no-cache-dir \33 aiohttp>=3.12.15 \34 aiomysql>=0.2.0 \35 aiosqlite>=0.21.0 \36 asyncpg>=0.30.0 \37 sqlmodel>=0.0.2438 39# Batch 2: AI/ML libraries and API clients40RUN pip install --no-cache-dir \41 anthropic>=0.60.0 \42 google-genai>=1.28.0 \43 openai>=1.98.044 45# Batch 3: Document processing and utilities46RUN pip install --no-cache-dir \47 dirtyjson>=1.0.8 \48 nltk>=3.9.1 \49 pathvalidate>=3.3.1 \50 pdfplumber>=0.11.7 \51 python-pptx>=1.0.252 53# Batch 4: FastAPI and testing54RUN pip install --no-cache-dir \55 fastapi[standard]>=0.116.1 \56 pytest>=8.4.157 58# Batch 5: AWS and security59RUN pip install --no-cache-dir \60 boto3>=1.34.0 \61 cryptography>=42.0.0 \62 redis>=6.2.063 64# Batch 6: Heavy dependencies (chromadb and docling) - installed last65RUN pip install --no-cache-dir chromadb>=1.0.1566RUN pip install --no-cache-dir docling>=2.43.0 --extra-index-url https://download.pytorch.org/whl/cpu67 68# Install dependencies for Next.js69WORKDIR /app/servers/nextjs70COPY servers/nextjs/package.json servers/nextjs/package-lock.json ./71RUN npm install72 73# Copy Next.js app74COPY servers/nextjs/ /app/servers/nextjs/75 76# Build the Next.js app77WORKDIR /app/servers/nextjs78RUN npm run build79 80WORKDIR /app81 82# Copy FastAPI83COPY servers/fastapi/ ./servers/fastapi/84COPY start.js LICENSE NOTICE ./85 86# Copy nginx configuration (Using HF specific config)87COPY nginx.hf.conf /etc/nginx/nginx.conf88 89# Expose the port (Hugging Face default)90EXPOSE 786091 92# Start the servers93CMD ["node", "/app/start.js"]94 