Spaces:
Sleeping
Sleeping
| # Use a slim Python image for a smaller container size. | |
| FROM python:3.13.5-slim | |
| # Set the working directory inside the container. | |
| WORKDIR /app | |
| # Install system dependencies needed for some Python packages. | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the requirements file first to leverage Docker's build cache. | |
| COPY requirements.txt ./ | |
| # Install Python dependencies. This step will re-run only if requirements.txt changes. | |
| RUN pip3 install -r requirements.txt | |
| # Copy the rest of the application files. | |
| COPY streamlit_app.py ./ | |
| COPY .streamlit/config.toml .streamlit/ | |
| # Create a non-root user to run the app. This is a security best practice. | |
| RUN useradd -ms /bin/bash streamlit | |
| RUN chown -R streamlit:streamlit /app | |
| USER streamlit | |
| # Expose the port Streamlit uses. | |
| EXPOSE 8501 | |
| # Add a health check to verify the app is running. | |
| HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health | |
| # Define the command to run the application. | |
| ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"] |