File size: 630 Bytes
3ec31f2
 
 
 
 
 
 
 
 
 
7893c81
3ec31f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9843ffa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# use the python 3.9
FROM python:3.9

# set the working directory
WORKDIR /code

# copy files to /code 
COPY ./requirements.txt /code/requirements.txt

# install requirements.txt 
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

#set up a new user named user
RUN useradd user
# switch user
USER user

# set home to users home dir
ENV HOME=/home/user \ 
    PATH=/home/user/.local/bin:$PATH 

# set the working dir to user's home dir
WORKDIR $HOME/app

# copy dir contents into container
COPY --chown=user . $HOME/app

#start fastapi on port 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]