# 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"]