FROM python:3.9-slim # Create a non-root user RUN useradd -m -u 1000 user # Set the working directory WORKDIR /home/user/app # Set environment variables ENV HOME=/home/user ENV PATH=/home/user/.local/bin:$PATH # Copy requirements.txt and install dependencies COPY --chown=user:user requirements.txt /home/user/app/requirements.txt RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY --chown=user:user . /home/user/app # Ensure the user has write permissions to the working directory RUN chown -R user:user /home/user/app # Switch to the non-root user USER user # Expose port 7860 EXPOSE 7860 # Run the app CMD ["chainlit", "run", "app.py", "--port", "7860"]