ClaimCheckAI / Dockerfile
Aryan Gosaliya
added permissions for writing
fcbf46d
Raw
History Blame
2.01 kB
# Stage 1: Build the React Frontend
FROM node:18-slim AS builder
WORKDIR /app
ENV HF_HOME=/app/.cache
# Copy frontend package files
COPY ui/claimcheck-ui/package.json ui/claimcheck-ui/pnpm-lock.yaml ./ui/claimcheck-ui/
# Install pnpm and dependencies
WORKDIR /app/ui/claimcheck-ui
RUN npm install -g pnpm && pnpm install --frozen-lockfile
# Copy frontend source code
COPY ui/claimcheck-ui/ ./
# Build the frontend with production API base URL
# Use Vite directly to skip TypeScript type checking if needed
ARG VITE_API_BASE=/
ENV VITE_API_BASE=${VITE_API_BASE}
ENV NODE_ENV=production
# Try to build with TypeScript checking, fall back to Vite build without tsc if it fails
RUN pnpm build || (echo "TypeScript check failed, building without type checking..." && npx vite build)
# Stage 2: Setup the Python Backend
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies for audio processing and ML libraries
RUN apt-get update && apt-get install -y \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend application code
COPY app ./app
COPY kb ./kb
COPY data ./data
# Copy the built frontend from the builder stage
COPY --from=builder /app/ui/claimcheck-ui/dist ./static
# Create necessary directories and fix permissions
RUN mkdir -p kb/index data/audio /.cache && \
chmod -R 777 data/audio && \
chmod -R 777 /.cache
# Set environment variables for production
ENV PYTHONUNBUFFERED=1
ENV HOST=0.0.0.0
ENV PORT=7860
ENV HF_HOME=/.cache
# Expose the port for Hugging Face Spaces
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:7860/health').raise_for_status()" || exit 1
# Command to run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]