# Use official Node.js LTS Alpine as base image for smaller size FROM node:18-alpine # Set working directory WORKDIR /app # Install system dependencies required for building native modules RUN apk add --no-cache python3 make g++ git # Install TypeScript globally to ensure tsc is available RUN npm install -g typescript@5.0.2 # Copy package.json and package-lock.json (if exists) COPY package*.json ./ # Install project dependencies explicitly RUN npm install --no-save \ react@18.2.0 \ react-dom@18.2.0 \ @types/react@18.2.15 \ @types/react-dom@18.2.7 \ typescript@5.0.2 \ @vitejs/plugin-react@4.0.3 \ vite@4.4.5 \ tailwindcss@3.3.0 \ postcss@8.4.24 \ autoprefixer@10.4.14 \ lucide-react@0.263.1 \ react-markdown@9.0.1 # Copy all project files COPY . . # Build the application RUN npm run build # Expose port 3000 (Hugging Face Spaces default) EXPOSE 3000 # Set environment variables ENV NODE_ENV=production ENV PORT=3000 # Start the application with Vite preview, ensuring port 3000 and no browser auto-open CMD ["npm", "run", "preview", "--", "--port", "3000", "--host", "0.0.0.0"]