rahul7star commited on
Commit
2aea684
·
verified ·
1 Parent(s): 6160079

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -21
Dockerfile CHANGED
@@ -1,27 +1,39 @@
1
  FROM python:3.10-slim
2
- RUN apt update && apt install -y git
3
 
4
- WORKDIR /code
 
5
 
6
- COPY ./requirements.txt /code/requirements.txt
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
9
 
10
- # Set up a new user named "user" with user ID 1000
11
- RUN useradd -m -u 1000 user
12
- # Switch to the "user" user
 
 
 
 
13
  USER user
14
- # Set home to the user's home directory
15
- ENV HOME=/home/user \
16
- PATH=/home/user/.local/bin:$PATH \
17
- PYTHONPATH=$HOME/app \
18
- PYTHONUNBUFFERED=1 \
19
-
20
-
21
- # Set the working directory to the user's home directory
22
- WORKDIR $HOME/app
23
-
24
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
25
- COPY --chown=user . $HOME/app
26
-
27
- CMD ["python", "app.py"]
 
1
  FROM python:3.10-slim
 
2
 
3
+ # Install git and other dependencies
4
+ RUN apt update && apt install -y git && apt clean
5
 
6
+ # Set up environment
7
+ ENV PYTHONUNBUFFERED=1 \
8
+ PORT=8000 \
9
+ HF_HOME=/home/user/huggingface \
10
+ GRADIO_ALLOW_FLAGGING=never \
11
+ GRADIO_NUM_PORTS=1 \
12
+ GRADIO_SERVER_NAME=0.0.0.0 \
13
+ GRADIO_THEME=huggingface \
14
+ SYSTEM=spaces \
15
+ PATH=/home/user/.local/bin:$PATH \
16
+ HOME=/home/user \
17
+ PYTHONPATH=/home/user/app
18
 
19
+ # Create user and required dirs
20
+ RUN useradd -m -u 1000 user && mkdir -p /home/user/huggingface /home/user/app
21
 
22
+ # Set working directory to user's app dir
23
+ WORKDIR /home/user/app
24
+
25
+ # Copy source as the correct user
26
+ COPY --chown=user . .
27
+
28
+ # Switch to user for safer permissions
29
  USER user
30
+
31
+ # Install Python dependencies
32
+ COPY requirements.txt /home/user/app/requirements.txt
33
+ RUN pip install --no-cache-dir -r /home/user/app/requirements.txt
34
+
35
+ # Expose the correct port
36
+ EXPOSE 8000
37
+
38
+ # Run FastAPI (no __main__ needed)
39
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]