rahul7star commited on
Commit
612944b
·
verified ·
1 Parent(s): 8aca36d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -17
Dockerfile CHANGED
@@ -1,24 +1,31 @@
1
- FROM python:3.10-slim
2
-
3
  RUN apt update && apt install -y git
4
 
5
- # Set environment variables
6
- ENV PYTHONUNBUFFERED=1 \
7
- PORT=8000 \
8
- HF_HOME=/home/user/huggingface
9
 
10
- # Create necessary folders
11
- RUN mkdir -p /home/user/huggingface
12
 
13
- # Install dependencies
14
- COPY requirements.txt .
15
- RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- # Copy app files
18
- COPY . .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- # Expose the port
21
- EXPOSE $PORT
22
 
23
- # Run the FastAPI app with uvicorn
24
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ FROM python:3.9
 
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
+ GRADIO_ALLOW_FLAGGING=never \
20
+ GRADIO_NUM_PORTS=1 \
21
+ GRADIO_SERVER_NAME=0.0.0.0 \
22
+ GRADIO_THEME=huggingface \
23
+ SYSTEM=spaces
24
+
25
+ # Set the working directory to the user's home directory
26
+ WORKDIR $HOME/app
27
 
28
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
29
+ COPY --chown=user . $HOME/app
30
 
31
+ CMD ["python", "app.py"]