Commit
·
29cc6b6
1
Parent(s):
985ca8d
fix: restructure Dockerfile to do all setup as root, then switch to user
Browse files- 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
|
| 24 |
|
| 25 |
-
# Install Python dependencies
|
| 26 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 27 |
-
pip install --no-cache-dir
|
| 28 |
|
| 29 |
# Copy application code
|
| 30 |
-
COPY
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
|
|
|
| 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
|