Spaces:
Sleeping
Sleeping
| # Use Python 3.12 slim image for smaller size | |
| FROM python:3.12-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV STREAMLIT_SERVER_PORT=8501 | |
| ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| software-properties-common \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application files | |
| COPY . . | |
| # Create a non-root user for security | |
| RUN useradd -m -u 1000 streamlit && chown -R streamlit:streamlit /app | |
| USER streamlit | |
| # Expose the port Streamlit runs on | |
| EXPOSE 8501 | |
| # Health check | |
| HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1 | |
| # Run the Streamlit application | |
| CMD ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"] |