File size: 1,029 Bytes
d75054c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9810c30
d75054c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dee3ee3
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
# Stage 1: Build the React Frontend
FROM node:18-alpine as build

WORKDIR /app

# Copy package files and install dependencies
COPY package.json vite.config.js ./
# We need to install the dependencies. 
# Since I cannot provide the full package-lock.json, we use 'npm install'
# Note: In a real repo, you would copy package-lock.json too.
RUN npm install

# Copy source code
COPY . .

# Build the app (outputs to /app/dist)
RUN npm run dev


# Stage 2: Setup the Python Backend
FROM python:3.9-slim

WORKDIR /app

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

# Copy Backend Code
COPY main.py .

# Copy Built Frontend Assets from Stage 1
COPY --from=build /app/dist ./dist

# Create a non-root user for security (Required by HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Expose the port HF Spaces expects (7860)
EXPOSE 7860

# Run FastAPI
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]