Rakshitjan commited on
Commit
a32bf70
·
verified ·
1 Parent(s): 527ea75

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -7
Dockerfile CHANGED
@@ -1,15 +1,30 @@
1
- # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
 
 
3
 
4
- FROM python:3.9
 
5
 
6
- WORKDIR /code
 
 
7
 
8
- COPY ./requirements.txt /code/requirements.txt
 
9
 
10
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
 
 
11
 
12
  COPY . .
13
 
14
- CMD uvicorn main:app --port=8000 --host=0.0.0.0
 
 
 
15
 
 
 
1
+ FROM python:3.12
2
+ ### Set up user with permissions
3
+ # Set up a new user named "user" with user ID 1000
4
+ RUN useradd -m -u 1000 user
5
 
6
+ # Switch to the "user" user
7
+ USER user
8
 
9
+ # Set home to the user's home directory
10
+ ENV HOME=/home/user \
11
+ PATH=/home/user/.local/bin:$PATH
12
 
13
+ # Set the working directory to the user's home directory
14
+ WORKDIR $HOME/app
15
 
16
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
17
+ COPY --chown=user . $HOME/app
18
+
19
+ ### Set up app-specific content
20
+ COPY requirements.txt requirements.txt
21
+ RUN pip3 install -r requirements.txt
22
 
23
  COPY . .
24
 
25
+ ### Update permissions for the app
26
+ USER root
27
+ RUN chmod 777 ~/app/*
28
+ USER user
29
 
30
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]