# Use an official Python runtime as a parent image FROM python:3.9 # Set a working directory for the application WORKDIR /app # Copy the Python and system requirements files to the container COPY ./requirements.txt /app/requirements.txt COPY ./app.py /app/app.py COPY ./src /app/src # RUN apt-get update && xargs -r -a /app/packages.txt apt-get install -y && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y \ build-essential \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # Upgrade pip, setuptools, and wheel, then install Python dependencies RUN pip install --upgrade pip setuptools wheel && pip install --no-cache-dir -r /app/requirements.txt # Create a non-root user and switch to it RUN useradd -m user USER user ENV HOME /home/user ENV PATH $HOME/.local/bin:$PATH # Copy the application source code to the container (as the non-root user) COPY --chown=user:user . $HOME/app # Set the working directory to the app directory WORKDIR $HOME/app # Expose the port the app runs on EXPOSE 8501 # Define the command to run the app CMD streamlit run app.py \ --server.headless true \ --server.address 0.0.0.0 \ --server.enableCORS false \ --server.enableXsrfProtection false \ --server.fileWatcherType none