FROM python:3.12 # Create a non-root user RUN useradd -m -u 1000 user # Set environment variables ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set working directory WORKDIR $HOME/app # Copy requirements and install dependencies COPY --chown=user requirements.txt $HOME/app/requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application COPY --chown=user . $HOME/app # Expose the port EXPOSE 7860 # Run the application CMD ["python", "app.py"]