FROM python:3.9 # Create a user with UID 1000 and create the necessary directories with appropriate permissions RUN useradd -m -u 1000 user && \ mkdir /home/user/app && \ chown user:user /home/user/app -R && \ chmod 755 /home/user/app -R # Switch to the new user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory (this will automatically switch to this directory) WORKDIR $HOME/app # Install dependencies # Note: Copying requirements.txt separately allows Docker to cache the installed packages unless requirements.txt changes COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of your application's code COPY --chown=user:user . . CMD ["chainlit", "run", "app.py", "--port", "7860"]