Spaces:
Running
Running
| FROM python:3.12.8-slim | |
| WORKDIR /app | |
| # System dependencies required for runtime | |
| # - curl for debugging | |
| # - git if needed by pip | |
| # - libfreetype6 and libpng16-16 required by matplotlib (Agg backend) | |
| # - fonts-dejavu-core for font rendering | |
| # - libglib2.0-0, libsm6, libxext6, libxrender1 are safe image libs some backends use | |
| # - ca-certificates to avoid TLS issues during pip installs and at runtime | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| ca-certificates \ | |
| libfreetype6 \ | |
| libpng16-16 \ | |
| fonts-dejavu-core \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Environment optimizations and Streamlit defaults | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| STREAMLIT_SERVER_HEADLESS=true \ | |
| STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \ | |
| MPLBACKEND=Agg \ | |
| MPLCONFIGDIR=/tmp/matplotlib | |
| # Upgrade pip tooling to avoid build failures | |
| RUN python -m pip install --upgrade pip setuptools wheel | |
| # Install Python dependencies first (layer caching) | |
| COPY requirements.txt ./ | |
| RUN pip3 install -r requirements.txt | |
| # Copy PWA injection files | |
| COPY pwa-head-inject.html ./pwa-head-inject.html | |
| COPY inject-pwa-head.sh ./inject-pwa-head.sh | |
| RUN chmod +x ./inject-pwa-head.sh && ./inject-pwa-head.sh | |
| # Copy application source | |
| COPY app.py ./app.py | |
| COPY battlewords ./battlewords | |
| COPY static ./static | |
| # Hugging Face Spaces sets $PORT (default 7860). Expose it for clarity. using 8501 for local consistency with Streamlit defaults | |
| EXPOSE 8501 | |
| HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health | |
| # Rely on Spaces health checking; do not add Docker HEALTHCHECK to avoid premature failures | |
| # Use shell form so $PORT expands at runtime | |
| ENTRYPOINT ["sh", "-c", "streamlit run app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"] |