# Use an official Python runtime as the base image FROM python:3.9-slim # Set up a new user named "user" with user ID 1000 RUN useradd -m -u 1000 user # Switch to the "user" user USER user # Set home to the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory to the user's home directory WORKDIR $HOME/app # Copy the setup.py file and the package directory into the container COPY --chown=user ./setup.py $HOME/app # Install the package and its dependencies COPY --chown=user ./src $HOME/app/src RUN pip install --no-cache-dir .[backend] torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cpu EXPOSE 7860 CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "7860"]