File size: 1,916 Bytes
ba28a1f
5e5d762
 
 
ba28a1f
 
 
 
 
 
 
f7535d7
ba28a1f
5e5d762
 
ba28a1f
 
 
 
 
 
 
 
5e5d762
 
f7535d7
 
 
 
 
 
ba28a1f
 
 
 
 
f7535d7
 
5e5d762
ba28a1f
5e5d762
1b1b6cc
 
 
 
 
f7535d7
 
 
1b1b6cc
5e5d762
ba28a1f
 
 
 
 
5e5d762
ba28a1f
5e5d762
f7535d7
ba28a1f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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"]