File size: 1,648 Bytes
ded8c75
5c89bd6
8d0377c
 
 
fb4db77
 
 
 
 
 
 
 
 
 
 
 
ded8c75
 
 
 
8d0377c
 
 
 
 
 
 
 
ded8c75
 
 
 
 
 
 
 
8d0377c
 
ded8c75
8d0377c
ded8c75
 
 
 
ea15c76
 
 
 
 
 
 
ded8c75
5c89bd6
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
# Start with a Python base image
FROM python:3.9
# Create a non-root user with ID 1000 (Required by Hugging Face)
RUN useradd -m -u 1000 user

# Install Node.js (for UI build) and OpenCV runtime system libs.
RUN apt-get update && \
    apt-get install -y --no-install-recommends curl ca-certificates gnupg && \
    curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y --no-install-recommends \
        nodejs \
        ffmpeg \
        libgl1 \
        libglib2.0-0 \
        libsm6 \
        libxext6 && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy your repository files and immediately give ownership to the new user
COPY --chown=user:user . .

# Switch away from the root user to the Hugging Face required user
USER user

# Ensure installed Python packages are added to the system path
ENV PATH="/home/user/.local/bin:${PATH}"

# 1. Build the React frontend
WORKDIR /app/ui
RUN npm install
RUN npm run build

# 2. Install Python dependencies
WORKDIR /app
# Upgrade pip first, then install requirements
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir uvicorn python-multipart

# Expose the default Hugging Face port
EXPOSE 7860

# Runtime model configuration (override these from HF Space Variables if needed)
ENV MODEL_DATASET=Dataset
ENV MODEL_TYPE=transformer
ENV MODEL_TRANSFORMER_SIZE=large
ENV MODEL_MAX_FRAME_LEN=169
ENV MODEL_CHECKPOINT=/app/transformer_large.pth

# Command to run your FastAPI application using Uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]