File size: 1,259 Bytes
7d3b4de
 
 
 
 
 
 
 
abd4352
803f4d0
abd4352
 
 
 
 
 
 
 
 
 
0e9e973
abd4352
 
 
 
803f4d0
abd4352
 
 
 
 
 
 
 
 
 
 
7d3b4de
 
 
abd4352
 
 
 
ffe8d09
 
abd4352
 
ffe8d09
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
# Build the Vite frontend
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
RUN npm run build

# Use an official Python runtime as a parent image
FROM python:3.11-slim-bookworm

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PORT=8000

# Set work directory
WORKDIR /app

# Install system dependencies (needed for some python packages like WeasyPrint)
RUN apt-get update && apt-get install -y \
    build-essential \
    python3-dev \
    libpangocairo-1.0-0 \
    libcairo2 \
    libgdk-pixbuf-2.0-0 \
    libffi-dev \
    shared-mime-info \
    && rm -rf /var/lib/apt/lists/*

# Install python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy project
COPY . .

# Copy the built frontend from the builder stage
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist

# Pre-download the embedding model so it's baked into the image
# This saves ~420MB of bandwidth on every deploy and makes starts instant
RUN python scripts/download_model.py

# Expose the port required by Hugging Face Spaces
EXPOSE 7860

# Start the application
CMD uvicorn api.main:app --host 0.0.0.0 --port 7860