File size: 1,191 Bytes
fa3af66
abf7059
 
fa3af66
 
 
 
 
 
abf7059
 
 
 
 
 
 
fa3af66
abf7059
 
 
 
fa3af66
 
 
 
 
 
 
 
abf7059
 
 
 
1459888
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
# Single-stage build: Node + Python in one image (avoids multi-stage cache issues)
FROM python:3.10-slim

# Install Node.js 20 as root
RUN apt-get update && apt-get install -y curl && \
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y nodejs && \
    rm -rf /var/lib/apt/lists/*

# Set up a new user named "user" with user ID 1000 (Required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /home/user/app

# Install Python dependencies (cached separately)
COPY --chown=user:user requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# Build React frontend (in same stage, no cross-stage cache issue)
COPY --chown=user:user frontend/package*.json ./frontend/
RUN cd frontend && npm install --ignore-scripts

COPY --chown=user:user frontend/ ./frontend/
RUN cd frontend && npm run build

# Copy remaining project files (does NOT overwrite frontend/dist/)
COPY --chown=user:user . .

EXPOSE 7860
ENV TRANSFORMERS_CACHE="/home/user/app/.cache/huggingface"
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]