Skip to content

Commit 2dadaba

Browse files
committed
Fix HF Spaces permission issue
1 parent 66fa2e0 commit 2dadaba

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

‎Dockerfile‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
FROM python:3.10-slim
22

3-
WORKDIR /app
3+
# Create user with ID 1000 (required by Hugging Face Spaces)
4+
RUN useradd -m -u 1000 user
45

5-
# Install dependencies
6-
COPY requirements.txt .
6+
# Switch to non-root user
7+
USER user
8+
9+
# Set home and paths
10+
ENV HOME=/home/user \
11+
PATH=/home/user/.local/bin:$PATH
12+
13+
# Set working directory to user home
14+
WORKDIR $HOME/app
15+
16+
# Copy requirements and install (chown to user)
17+
COPY --chown=user requirements.txt .
718
RUN pip install --no-cache-dir -r requirements.txt
819

9-
# Copy source code
10-
COPY . .
20+
# Copy source code (chown to user)
21+
COPY --chown=user . .
1122

1223
# Generate Embeddings and build the embedded ChromaDB index during the Docker build
1324
RUN python embed.py

0 commit comments

Comments
 (0)