KOOHAWN/AI_PDF_TOOLKIt
0
1# ==========================================2# STAGE 1: Build static React frontend assets3# ==========================================4FROM node:20-slim AS builder5WORKDIR /app6 7# Install dependencies (including devDependencies like Vite and TypeScript)8COPY package*.json ./9RUN npm install10 11# Copy source code and build the production bundle12COPY . .13RUN npm run build14 15# ==========================================16# STAGE 2: Secure, production runtime container17# ==========================================18FROM node:20-slim19 20# Install system dependencies (Ghostscript & MuPDF tools)21RUN apt-get update && apt-get install -y \22 ghostscript \23 mupdf-tools \24 && rm -rf /var/lib/apt/lists/*25 26WORKDIR /app27ENV NODE_ENV=production28ENV PORT=786029 30# Install only production runtime npm packages31COPY package*.json ./32RUN npm install --production33 34# Copy built React frontend bundle from the builder stage35COPY --from=builder /app/dist ./dist36 37# Copy backend server files38COPY server.cjs ./39COPY workers/ ./workers/40COPY lib/ ./lib/41COPY *.traineddata ./42 43# Hugging Face Spaces compatibility: Run as non-root user (UID 1000)44RUN chown -R 1000:1000 /app && chmod -R 775 /app45USER 100046 47# Expose default API port for Hugging Face Spaces48EXPOSE 786049 50# Start the unified web application (React UI + Express API Backend)51CMD ["node", "server.cjs"]52 