Lcmind commited on
Commit
8f79fe0
·
1 Parent(s): 6ad0b3c

fix: add HF Spaces required user (UID 1000) and proper permissions

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -11
Dockerfile CHANGED
@@ -38,21 +38,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
38
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
39
  PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
40
 
41
- # Create app directory with proper permissions
42
- WORKDIR /app
43
- RUN chmod 777 /app
44
 
45
- # Install uv (ultra-fast Python package installer)
46
- RUN pip install --no-cache-dir uv
47
 
48
- # Copy dependency files first (layer caching optimization)
49
- COPY requirements.txt .
 
50
 
51
- # Install Python dependencies with uv (10-100x faster than pip)
52
- RUN uv pip install --system --no-cache -r requirements.txt
53
 
54
- # Copy application code
55
- COPY . .
 
 
 
 
 
56
 
57
  # Expose Hugging Face Spaces port
58
  EXPOSE 7860
 
38
  ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
39
  PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
40
 
41
+ # HF Spaces requirement: Create user with UID 1000
42
+ RUN useradd -m -u 1000 user
 
43
 
44
+ # Switch to user
45
+ USER user
46
 
47
+ # Set home and PATH for user
48
+ ENV HOME=/home/user \
49
+ PATH=/home/user/.local/bin:$PATH
50
 
51
+ # Set working directory
52
+ WORKDIR $HOME/app
53
 
54
+ # Install uv for the user
55
+ RUN pip install --no-cache-dir --user uv
56
+
57
+ # Copy requirements with proper ownership
58
+ COPY --chown=user requirements.txt .
59
+
60
+ # Run FastAPI on port 7860 with proxy headers
61
 
62
  # Expose Hugging Face Spaces port
63
  EXPOSE 7860