# Use the official lightweight Python image. # "Slim" keeps the file size down (better for cloud costs). FROM python:3.9-slim # Set the working directory inside the container WORKDIR /app # Prevent Python from writing pyc files to disc (useless in containers) ENV PYTHONDONTWRITEBYTECODE=1 # Prevent Python from buffering stdout/stderr (so you see logs immediately) ENV PYTHONUNBUFFERED=1 # Install system dependencies (sometimes needed for Plotly/Pandas) RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ && rm -rf /var/lib/apt/lists/* # Copy the requirements file first (for better caching) COPY requirements.txt . # Install Python dependencies RUN pip3 install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY . . # Expose the port Streamlit runs on EXPOSE 8501 # The Healthcheck (Critical for "High Availability" systems) HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1 # Command to run the app # address=0.0.0.0 is MANDATORY for Docker ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]