LogicGoInfotechSpaces commited on
Commit
985ca8d
·
1 Parent(s): 08f4a13

fix: use python:3.10-slim base image for better HF Spaces compatibility

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -38
Dockerfile CHANGED
@@ -1,12 +1,10 @@
1
  # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # GPU-optimized Dockerfile for Face Swap Video API
3
 
4
- FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04
5
 
6
  # Install system dependencies
7
  RUN apt-get update && apt-get install -y \
8
- python3.10 \
9
- python3-pip \
10
  ffmpeg \
11
  libgl1-mesa-glx \
12
  libglib2.0-0 \
@@ -15,54 +13,30 @@ RUN apt-get update && apt-get install -y \
15
 
16
  # Create user for Hugging Face Spaces (following HF Spaces best practices)
17
  RUN useradd -m -u 1000 user
 
 
18
 
19
  # Set working directory
20
  WORKDIR /app
21
 
22
- # Create upload directories first
23
- RUN mkdir -p uploads/source_images uploads/target_videos uploads/result_videos uploads/output
24
-
25
  # Copy requirements file
26
- COPY requirements.txt requirements.txt
27
 
28
- # Install Python dependencies as root first
29
- RUN pip3 install --no-cache-dir --upgrade pip && \
30
- pip3 install --no-cache-dir \
31
- fastapi>=0.115.2 \
32
- uvicorn[standard]==0.24.0 \
33
- python-multipart>=0.0.18 \
34
- motor==3.3.2 \
35
- pymongo==4.6.0 \
36
- python-dotenv==1.0.0 \
37
- dnspython==2.4.2 \
38
- numpy==1.24.3 \
39
- insightface==0.7.3 \
40
- onnxruntime-gpu==1.17.3 \
41
- opencv-python \
42
- psutil==5.9.5 \
43
- tqdm==4.65.0 \
44
- Pillow \
45
- moviepy==1.0.3 \
46
- imageio-ffmpeg \
47
- huggingface_hub>=0.23.0
48
 
49
  # Copy application code
50
- COPY . /app
51
 
52
- # Set ownership and permissions
53
- RUN chown -R user:user /app && \
54
- chmod -R 755 uploads
55
-
56
- # Switch to user
57
- USER user
58
- ENV PATH="/home/user/.local/bin:$PATH"
59
 
60
  # Set environment variables
61
  ENV PYTHONUNBUFFERED=1
62
- ENV CUDA_VISIBLE_DEVICES=0
63
 
64
  # Expose port 7860 (required for Hugging Face Spaces)
65
  EXPOSE 7860
66
 
67
  # Run the API server on port 7860 (HF Spaces requirement)
68
- CMD ["python3", "-m", "uvicorn", "api_server:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # Dockerfile for Face Swap Video API
3
 
4
+ FROM python:3.10-slim
5
 
6
  # Install system dependencies
7
  RUN apt-get update && apt-get install -y \
 
 
8
  ffmpeg \
9
  libgl1-mesa-glx \
10
  libglib2.0-0 \
 
13
 
14
  # Create user for Hugging Face Spaces (following HF Spaces best practices)
15
  RUN useradd -m -u 1000 user
16
+ USER user
17
+ ENV PATH="/home/user/.local/bin:$PATH"
18
 
19
  # Set working directory
20
  WORKDIR /app
21
 
 
 
 
22
  # Copy requirements file
23
+ COPY --chown=user:user ./requirements.txt requirements.txt
24
 
25
+ # Install Python dependencies
26
+ RUN pip install --no-cache-dir --upgrade pip && \
27
+ pip install --no-cache-dir --user -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  # Copy application code
30
+ COPY --chown=user:user . /app
31
 
32
+ # Create upload directories
33
+ RUN mkdir -p uploads/source_images uploads/target_videos uploads/result_videos uploads/output
 
 
 
 
 
34
 
35
  # Set environment variables
36
  ENV PYTHONUNBUFFERED=1
 
37
 
38
  # Expose port 7860 (required for Hugging Face Spaces)
39
  EXPOSE 7860
40
 
41
  # Run the API server on port 7860 (HF Spaces requirement)
42
+ CMD ["python", "-m", "uvicorn", "api_server:app", "--host", "0.0.0.0", "--port", "7860"]