qgallouedec HF Staff commited on
Commit
9106161
·
verified ·
1 Parent(s): f612c15

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -7
Dockerfile CHANGED
@@ -1,16 +1,25 @@
1
- # Use a lightweight Python image as the base
2
- FROM python:3.11-slim
3
 
4
- # Set the working directory inside the container
5
- WORKDIR /app
 
 
 
 
 
6
 
7
- # Copy all files to the container
8
- COPY . /app
 
 
 
 
 
 
9
 
10
  # Install gradio
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
-
14
  EXPOSE 7860
15
  ENV GRADIO_SERVER_NAME="0.0.0.0"
16
 
 
1
+ FROM python:3.11
 
2
 
3
+ # Set up a new user named "user" with user ID 1000
4
+ RUN useradd -m -u 1000 user
5
+ # Switch to the "user" user
6
+ USER user
7
+ # Set home to the user's home directory
8
+ ENV HOME=/home/user \
9
+ PATH=/home/user/.local/bin:$PATH
10
 
11
+ # Set the working directory to the user's home directory
12
+ WORKDIR $HOME/app
13
+
14
+ # Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
15
+ RUN pip install --no-cache-dir --upgrade pip
16
+
17
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
18
+ COPY --chown=user . README.md $HOME/app/
19
 
20
  # Install gradio
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
 
23
  EXPOSE 7860
24
  ENV GRADIO_SERVER_NAME="0.0.0.0"
25