kirubel1738 commited on
Commit
a9ff387
·
verified ·
1 Parent(s): 3abed2e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -7
Dockerfile CHANGED
@@ -1,20 +1,41 @@
 
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
+ # Dockerfile - Streamlit app for huggingface model
2
  FROM python:3.13.5-slim
3
 
4
+ ENV PYTHONUNBUFFERED=1 \
5
+ HF_HOME=/tmp/huggingface \
6
+ TRANSFORMERS_CACHE=/tmp/huggingface/transformers \
7
+ HF_DATASETS_CACHE=/tmp/huggingface/datasets \
8
+ HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub \
9
+ XDG_CACHE_HOME=/tmp/huggingface \
10
+ HOME=/tmp
11
+
12
  WORKDIR /app
13
 
14
+ # Install system deps
15
+ RUN apt-get update && apt-get install -y --no-install-recommends \
16
  build-essential \
 
17
  git \
18
+ curl \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # create cache dirs early (prevents permission errors in Spaces)
22
+ RUN mkdir -p /tmp/huggingface/transformers /tmp/huggingface/datasets /tmp/huggingface/hub \
23
+ && chmod -R 777 /tmp/huggingface
24
+
25
+ # copy requirements and install
26
+ COPY requirements.txt /app/requirements.txt
27
+ RUN python -m pip install --upgrade pip
28
+ RUN pip install -r /app/requirements.txt
29
 
30
+ # copy app
31
+ COPY . /app
32
 
33
+ # Expose Streamlit port (Spaces and local Streamlit default)
34
  EXPOSE 8501
35
 
36
+ # Healthcheck (simple)
37
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
38
+ CMD curl --fail http://localhost:8501/_stcore/health || exit 1
39
 
40
+ # Start streamlit
41
+ ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.headless=true", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]