File size: 1,824 Bytes
8608e55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217fdad
 
 
 
8608e55
217fdad
 
 
8608e55
 
 
 
 
 
 
 
08395e2
 
8608e55
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
# ---------- Stage 1: build React (under app/) ----------
FROM node:20-alpine AS fe
WORKDIR /fe

# Copy manifests explicitly from app/
COPY app/package.json ./
COPY app/package-lock.json ./

# Debug: verify files arrived
RUN echo "LIST /fe after copying manifests:" && ls -la

# Use lockfile if present; otherwise fallback to npm install
RUN if [ -f package-lock.json ]; then npm ci --no-audit; else npm install; fi

# Copy the rest of the frontend source
COPY app/ .

# Build Vite app -> /fe/dist
RUN npm run build
RUN echo "LIST /fe/dist after build:" && ls -la /fe/dist

# ---------- Stage 2: FastAPI runtime ----------
FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

# System libs for OpenCV/EasyOCR
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential libgl1 libglib2.0-0 ca-certificates \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy backend code
COPY backend/ /app/backend/

# Copy built frontend into the folder FastAPI serves
COPY --from=fe /fe/dist/ /app/backend/frontend/

# Python deps (Torch CPU first)
#RUN pip install --no-cache-dir --upgrade pip \
# && pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu \


RUN pip install --no-cache-dir --upgrade pip \
 && pip uninstall -y torch torchvision torchaudio || true \
 && pip install --no-cache-dir torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cpu \
 && pip install --no-cache-dir easyocr==1.7.1 \
&& pip install --no-cache-dir -r backend/requirements.txt \
&& pip install --no-cache-dir uvicorn==0.30.1


# Hugging Face port + persistent DB path
ENV PORT=7860
ENV DB_PATH=/data/sessions.db

RUN mkdir -p /data && chmod 777 /data

CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860"]