Commit
·
3176415
1
Parent(s):
7658264
fix: restructure Dockerfile to install packages as root, then switch to user
Browse files- Dockerfile +12 -9
Dockerfile
CHANGED
|
@@ -15,18 +15,16 @@ 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 |
-
USER user
|
| 19 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
| 20 |
|
| 21 |
# Set working directory
|
| 22 |
WORKDIR /app
|
| 23 |
|
| 24 |
# Copy requirements file
|
| 25 |
-
COPY
|
| 26 |
|
| 27 |
-
# Install Python dependencies
|
| 28 |
-
RUN
|
| 29 |
-
|
| 30 |
fastapi>=0.115.2 \
|
| 31 |
uvicorn[standard]==0.24.0 \
|
| 32 |
python-multipart>=0.0.18 \
|
|
@@ -46,11 +44,16 @@ RUN pip install --no-cache-dir --upgrade pip && \
|
|
| 46 |
huggingface_hub>=0.23.0
|
| 47 |
|
| 48 |
# Copy application code
|
| 49 |
-
COPY
|
| 50 |
|
| 51 |
# Create upload directories with proper permissions
|
| 52 |
RUN mkdir -p uploads/source_images uploads/target_videos uploads/result_videos uploads/output && \
|
| 53 |
-
chmod -R 755 uploads
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
# Set environment variables
|
| 56 |
ENV PYTHONUNBUFFERED=1
|
|
@@ -60,4 +63,4 @@ ENV CUDA_VISIBLE_DEVICES=0
|
|
| 60 |
EXPOSE 7860
|
| 61 |
|
| 62 |
# Run the API server on port 7860 (HF Spaces requirement)
|
| 63 |
-
CMD ["uvicorn", "api_server:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 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 |
# Copy requirements file
|
| 23 |
+
COPY requirements.txt requirements.txt
|
| 24 |
|
| 25 |
+
# Install Python dependencies as root first
|
| 26 |
+
RUN pip3 install --no-cache-dir --upgrade pip && \
|
| 27 |
+
pip3 install --no-cache-dir \
|
| 28 |
fastapi>=0.115.2 \
|
| 29 |
uvicorn[standard]==0.24.0 \
|
| 30 |
python-multipart>=0.0.18 \
|
|
|
|
| 44 |
huggingface_hub>=0.23.0
|
| 45 |
|
| 46 |
# Copy application code
|
| 47 |
+
COPY . /app
|
| 48 |
|
| 49 |
# Create upload directories with proper permissions
|
| 50 |
RUN mkdir -p uploads/source_images uploads/target_videos uploads/result_videos uploads/output && \
|
| 51 |
+
chmod -R 755 uploads && \
|
| 52 |
+
chown -R user:user /app
|
| 53 |
+
|
| 54 |
+
# Switch to user
|
| 55 |
+
USER user
|
| 56 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 57 |
|
| 58 |
# Set environment variables
|
| 59 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
| 63 |
EXPOSE 7860
|
| 64 |
|
| 65 |
# Run the API server on port 7860 (HF Spaces requirement)
|
| 66 |
+
CMD ["python3", "-m", "uvicorn", "api_server:app", "--host", "0.0.0.0", "--port", "7860"]
|