File size: 731 Bytes
5ec8ce9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
# use the official python image
FROM python:3.11

# set the workinf directory to /code
WORKDIR /code

# copy the current directory content in container at /code
COPY ./requirements.txt /code/requirements.txt

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

# setup new user
RUN useradd user

# switch to user
USER user

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

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

# copy current dir content into container at $HOME/app
COPY --chown=user . $HOME/app

# start FASTAPI app on port 8000
CMD ["uvicorn","app:app","--host","0.0.0.0","--port","8000"]