# Use an official Python runtime as a parent image FROM python:3.9 # Create app directory WORKDIR /app # Copy the Python requirements file and system packages list COPY ./requirements.txt /app/requirements.txt # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies RUN pip install --upgrade pip setuptools wheel && \ pip install --no-cache-dir -r /app/requirements.txt # Create a non-root user RUN useradd -m -u 1000 user USER user ENV HOME /home/user ENV PATH $HOME/.local/bin:$PATH # Copy the application to the user's home directory WORKDIR $HOME COPY --chown=user:user . $HOME/app # Set the working directory to the app directory WORKDIR $HOME/app # Expose the Streamlit port EXPOSE 8501 # Run the Streamlit application with additional configurations for cloud deployment CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.headless=true", "--server.enableCORS=false", "--server.enableXsrfProtection=false", "--server.fileWatcherType=none"]