MalikShehram commited on
Commit
f0df565
·
verified ·
1 Parent(s): 3b8577d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -7
Dockerfile CHANGED
@@ -1,17 +1,26 @@
1
  # Use an official Python runtime as a base image
2
  FROM python:3.10-slim
3
 
4
- # Set the working directory in the container
5
- WORKDIR /app
 
6
 
7
- # Copy the requirements file into the container
8
- COPY requirements.txt .
9
 
10
- # Install dependencies
 
 
 
 
 
 
 
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy the rest of the application files
14
- COPY . .
15
 
16
  # Hugging Face Spaces route traffic to port 7860 by default
17
  EXPOSE 7860
 
1
  # Use an official Python runtime as a base image
2
  FROM python:3.10-slim
3
 
4
+ # Set up a new user named "user" with user ID 1000
5
+ # (This is strictly recommended by Hugging Face to avoid permission issues)
6
+ RUN useradd -m -u 1000 user
7
 
8
+ # Switch to the "user" user
9
+ USER user
10
 
11
+ # Set home to the user's home directory
12
+ ENV HOME=/home/user \
13
+ PATH=/home/user/.local/bin:$PATH
14
+
15
+ # Set the working directory to the user's app directory
16
+ WORKDIR $HOME/app
17
+
18
+ # Copy the requirements file and install them
19
+ COPY --chown=user requirements.txt .
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
+ # Copy the rest of the application files and set ownership
23
+ COPY --chown=user . $HOME/app
24
 
25
  # Hugging Face Spaces route traffic to port 7860 by default
26
  EXPOSE 7860