LogicGoInfotechSpaces commited on
Commit
29cc6b6
·
1 Parent(s): 985ca8d

fix: restructure Dockerfile to do all setup as root, then switch to user

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -8
Dockerfile CHANGED
@@ -13,24 +13,28 @@ RUN apt-get update && apt-get install -y \
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
 
13
 
14
  # Create user for Hugging Face Spaces (following HF Spaces best practices)
15
  RUN useradd -m -u 1000 user
 
 
16
 
17
  # Set working directory
18
  WORKDIR /app
19
 
20
  # Copy requirements file
21
+ COPY requirements.txt requirements.txt
22
 
23
+ # Install Python dependencies as root
24
  RUN pip install --no-cache-dir --upgrade pip && \
25
+ pip install --no-cache-dir -r requirements.txt
26
 
27
  # Copy application code
28
+ COPY . /app
29
+
30
+ # Create upload directories and set ownership
31
+ RUN mkdir -p uploads/source_images uploads/target_videos uploads/result_videos uploads/output && \
32
+ chown -R user:user /app && \
33
+ chmod -R 755 uploads
34
 
35
+ # Switch to user
36
+ USER user
37
+ ENV PATH="/home/user/.local/bin:$PATH"
38
 
39
  # Set environment variables
40
  ENV PYTHONUNBUFFERED=1