FROM python:3.9 # Set working directory WORKDIR /code # Copy requirements file and install dependencies COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Create a non-root user RUN useradd user # Set environment variables ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Switch to the non-root user USER user # Set working directory for the application WORKDIR $HOME/app # Copy application code into the container COPY --chown=user . $HOME/app # Expose port EXPOSE 7860 # Command to run the FastAPI application using uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]