# Use the official Python 3.10 slim image as the base FROM python:3.10-slim # Set environment variables to ensure consistent behavior ENV PYTHONUNBUFFERED=1 \ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \ STREAMLIT_SERVER_HEADLESS=true \ STREAMLIT_HOME=/tmp/.streamlit # Create the .streamlit directory with appropriate permissions RUN mkdir -p $STREAMLIT_HOME && chmod -R 755 $STREAMLIT_HOME # Set the working directory in the container WORKDIR /app # Copy only the requirements file first to leverage Docker cache COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . . # Expose the port Streamlit will run on EXPOSE 8501 # Define the command to run the Streamlit app CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]