Surn commited on
Commit
ba28a1f
·
1 Parent(s): 748dddb

Dockerfile fix

Browse files
Files changed (2) hide show
  1. Dockerfile +30 -9
  2. README.md +2 -1
Dockerfile CHANGED
@@ -1,11 +1,26 @@
1
- FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
- # System dependencies required for runtime and healthcheck
 
 
 
 
 
 
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
7
  curl \
8
  git \
 
 
 
 
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  # Environment optimizations and Streamlit defaults
@@ -14,21 +29,27 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
14
  PIP_NO_CACHE_DIR=1 \
15
  STREAMLIT_SERVER_HEADLESS=true \
16
  STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
17
- MPLBACKEND=Agg
 
 
 
 
18
 
19
  # Install Python dependencies first (layer caching)
20
  COPY requirements.txt ./
21
- RUN pip install --no-cache-dir -r requirements.txt
22
 
23
  # Copy application source
24
  COPY app.py ./app.py
25
  COPY battlewords ./battlewords
26
 
27
- # Hugging Face Spaces sets $PORT (default 7860). Expose it for clarity.
28
- EXPOSE 7860
 
 
 
29
 
30
- # Healthcheck against the dynamic port
31
- HEALTHCHECK CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
32
 
33
  # Use shell form so $PORT expands at runtime
34
- ENTRYPOINT ["sh", "-c", "streamlit run app.py --server.port=${PORT:-7860} --server.address=0.0.0.0"]
 
1
+ FROM python:3.12.8-slim
2
 
3
  WORKDIR /app
4
 
5
+ # System dependencies required for runtime
6
+ # - curl for debugging
7
+ # - git if needed by pip
8
+ # - libfreetype6 and libpng16-16 required by matplotlib (Agg backend)
9
+ # - fonts-dejavu-core for font rendering
10
+ # - libglib2.0-0, libsm6, libxext6, libxrender1 are safe image libs some backends use
11
+ # - ca-certificates to avoid TLS issues during pip installs and at runtime
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
13
+ build-essential \
14
  curl \
15
  git \
16
+ ca-certificates \
17
+ libfreetype6 \
18
+ libpng16-16 \
19
+ fonts-dejavu-core \
20
+ libglib2.0-0 \
21
+ libsm6 \
22
+ libxext6 \
23
+ libxrender1 \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
  # Environment optimizations and Streamlit defaults
 
29
  PIP_NO_CACHE_DIR=1 \
30
  STREAMLIT_SERVER_HEADLESS=true \
31
  STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
32
+ MPLBACKEND=Agg \
33
+ MPLCONFIGDIR=/tmp/matplotlib
34
+
35
+ # Upgrade pip tooling to avoid build failures
36
+ RUN python -m pip install --upgrade pip setuptools wheel
37
 
38
  # Install Python dependencies first (layer caching)
39
  COPY requirements.txt ./
40
+ RUN pip3 install -r requirements.txt
41
 
42
  # Copy application source
43
  COPY app.py ./app.py
44
  COPY battlewords ./battlewords
45
 
46
+ # Hugging Face Spaces sets $PORT (default 7860). Expose it for clarity. using 8501 for local consistency with Streamlit defaults
47
+
48
+ EXPOSE 8501
49
+
50
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
51
 
52
+ # Rely on Spaces health checking; do not add Docker HEALTHCHECK to avoid premature failures
 
53
 
54
  # Use shell form so $PORT expands at runtime
55
+ ENTRYPOINT ["sh", "-c", "streamlit run app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]
README.md CHANGED
@@ -5,7 +5,8 @@ colorFrom: blue
5
  colorTo: indigo
6
  sdk: streamlit
7
  sdk_version: 1.25.0
8
- python_version: 3.10
 
9
  app_file: app.py
10
  tags:
11
  - game
 
5
  colorTo: indigo
6
  sdk: streamlit
7
  sdk_version: 1.25.0
8
+ python_version: 3.12.8
9
+ app_port: 8501
10
  app_file: app.py
11
  tags:
12
  - game