Surn commited on
Commit
f7535d7
·
1 Parent(s): a749bc0

Add dockerfile v1

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -8
Dockerfile CHANGED
@@ -1,20 +1,34 @@
1
- FROM python:3.13.5-slim
2
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
  curl \
8
  git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
 
 
 
 
 
 
 
 
 
11
  COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
14
- RUN pip3 install -r requirements.txt
 
 
15
 
16
- EXPOSE 8501
 
17
 
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
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
12
+ ENV PYTHONDONTWRITEBYTECODE=1 \
13
+ PYTHONUNBUFFERED=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"]