sathishaiuse commited on
Commit
a6aa3fe
·
verified ·
1 Parent(s): f0de5d8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -25
Dockerfile CHANGED
@@ -1,37 +1,26 @@
1
- # Dockerfile predownload model at build time (recommended)
2
  FROM python:3.11-slim
3
 
4
- ENV DEBIAN_FRONTEND=noninteractive
 
 
 
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # system deps
8
- RUN apt-get update && apt-get install -y --no-install-recommends \
9
- ca-certificates libgomp1 && rm -rf /var/lib/apt/lists/*
10
 
11
- # copy code & requirements
12
  COPY . /app
13
 
14
- # upgrade pip
15
  RUN python -m pip install --upgrade pip setuptools wheel
16
-
17
- # install only Python deps first
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
- # Download model from HF into /opt/model at build-time
21
- # If repo is private, set build secret or pass HF_TOKEN as build-arg (see notes below)
22
- ARG HF_MODEL_REPO="sathishaiuse/wellness-classifier-model"
23
- ARG HF_MODEL_FILENAME=""
24
- ARG HF_TOKEN=""
25
- RUN python - <<PY
26
- from huggingface_hub import snapshot_download
27
- import os
28
- repo = os.environ.get('HF_MODEL_REPO', '${HF_MODEL_REPO}')
29
- token = os.environ.get('HF_TOKEN', '${HF_TOKEN}') or None
30
- # snapshot_download will save the repo files into /opt/model/<repo-name>
31
- local = snapshot_download(repo, token=token, cache_dir="/opt/model_cache")
32
- print("Downloaded to:", local)
33
- PY
34
-
35
  # create unpriv user
36
  RUN useradd -m -u 1000 user
37
  USER user
@@ -40,4 +29,8 @@ WORKDIR $HOME/app
40
  RUN cp -r /app/* $HOME/app/ || true
41
 
42
  EXPOSE 8501
43
- CMD ["streamlit","run","app.py","--server.port=8501","--server.address=0.0.0.0"]
 
 
 
 
 
1
+ # Dockerfile for HF Space (use python 3.11 for compatibility)
2
  FROM python:3.11-slim
3
 
4
+ ENV DEBIAN_FRONTEND=noninteractive \
5
+ PYTHONUNBUFFERED=1 \
6
+ STREAMLIT_SERVER_HEADLESS=true \
7
+ STREAMLIT_SERVER_RUN_ON_SAVE=false \
8
+ STREAMLIT_SERVER_ENABLECORS=false \
9
+ STREAMLIT_SERVER_PORT=8501 \
10
+ STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
11
+ STREAMLIT_SERVER_MAX_UPLOADED_FILE_SIZE=200
12
+
13
  WORKDIR /app
14
 
15
+ # small runtime deps
16
+ RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 ca-certificates && rm -rf /var/lib/apt/lists/*
 
17
 
 
18
  COPY . /app
19
 
20
+ # upgrade pip and install deps
21
  RUN python -m pip install --upgrade pip setuptools wheel
 
 
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  # create unpriv user
25
  RUN useradd -m -u 1000 user
26
  USER user
 
29
  RUN cp -r /app/* $HOME/app/ || true
30
 
31
  EXPOSE 8501
32
+
33
+ # run streamlit with logger level debug
34
+ CMD ["streamlit", "run", "app.py", \
35
+ "--server.port=8501", "--server.address=0.0.0.0", \
36
+ "--logger.level=debug", "--server.headless=true", "--server.runOnSave=false"]