FROM python:3.9 WORKDIR /code COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # Create a non-root user and switch to it RUN useradd -m -u 1000 user USER user # Set environment variables ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ HF_HOME=/home/user/.cache/huggingface/transformers WORKDIR $HOME/app # Ensure the user owns the copied files COPY --chown=user . $HOME/app # Command to run the application with Uvicorn CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]