File size: 1,760 Bytes
c57d186 c4089f6 c57d186 c4089f6 c57d186 b4f606e c4089f6 c57d186 ba4786f c57d186 c4089f6 716cac1 ba4786f 1328d81 ba4786f 1328d81 c4089f6 6c671a5 c4089f6 985928b 6c671a5 c4089f6 c57d186 ba4786f c57d186 ba4786f c57d186 c4089f6 c57d186 c4089f6 c57d186 43544c3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# --- Stage 1: Build React frontend ---
FROM node:20-alpine AS frontend
WORKDIR /app/frontend
# Install dependencies
COPY frontend/package*.json ./
COPY frontend/package-lock.json ./
RUN npm install --frozen-lockfile
# Build frontend
COPY frontend/ ./
RUN npm run build
# --- Stage 2: Python backend (CPU only) ---
FROM python:3.10-slim AS backend
# Environment setup
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/app/.cache/huggingface
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git curl && \
rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m appuser
# Create necessary directories and set permissions
RUN mkdir -p /app/.cache/huggingface \
&& mkdir -p /app/static \
&& chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
WORKDIR /app
# Upgrade pip and install Python dependencies
COPY backend/requirements.txt /app/backend/requirements.txt
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install -r /app/backend/requirements.txt
# Copy backend code
COPY backend/ /app/backend/
# Copy frontend build to static directory
COPY --from=frontend /app/frontend/dist/ /app/static/
# App-specific environment variables
ENV STATIC_DIR=/app/static \
MODEL_ID=FractalAIResearch/Fathom-R1-14B \
PIPELINE_TASK=text-generation \
QUANTIZE=auto
# Optional: Healthcheck endpoint
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
EXPOSE 7860
ENTRYPOINT ["python3", "-m", "uvicorn", "app.main:app", "--app-dir", "/app/backend", "--host", "0.0.0.0", "--port", "7860"] |