mazen2100 commited on
Commit
4fd1fb0
·
verified ·
1 Parent(s): 6a3f555

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -5
Dockerfile CHANGED
@@ -1,14 +1,36 @@
 
 
 
1
  FROM python:3.9-slim
 
 
2
  WORKDIR /app
3
 
4
- ENV STREAMLIT_HOME=/app/.streamlit
5
- ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/hub
6
- RUN mkdir -p /app/.streamlit /app/.cache/huggingface/hub
 
 
 
7
 
 
 
 
 
 
 
 
8
  COPY requirements.txt .
9
  RUN pip install --no-cache-dir -r requirements.txt
10
 
11
- COPY . .
 
 
12
 
 
13
  EXPOSE 8501
14
- CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
 
 
1
+ # Dockerfile for Streamlit app in `src/` folder with Transformers cache fix
2
+
3
+ # 1. Base image
4
  FROM python:3.9-slim
5
+
6
+ # 2. Set working directory
7
  WORKDIR /app
8
 
9
+ # 3. Environment variables for writable cache/config dirs
10
+ ENV STREAMLIT_CONFIG_DIR=/app/.streamlit \
11
+ TRANSFORMERS_CACHE=/app/.cache/huggingface/hub \
12
+ HF_HOME=/app/.cache/huggingface \
13
+ XDG_CACHE_HOME=/app/.cache \
14
+ STREAMLIT_HOME=/app/.cache/streamlit
15
 
16
+ # 4. Create directories with correct permissions
17
+ RUN mkdir -p /app/.streamlit \
18
+ && mkdir -p /app/.cache/huggingface/hub \
19
+ && mkdir -p /app/.cache/streamlit \
20
+ && chmod -R 777 /app/.cache /app/.streamlit
21
+
22
+ # 5. Copy in dependency file and install
23
  COPY requirements.txt .
24
  RUN pip install --no-cache-dir -r requirements.txt
25
 
26
+ # 6. Copy your source app code
27
+ COPY src/ ./src
28
+ COPY .streamlit/config.toml /app/.streamlit/config.toml
29
 
30
+ # 7. Expose Streamlit default port
31
  EXPOSE 8501
32
+
33
+ # 8. Launch Streamlit pointing to src/app.py
34
+ CMD ["streamlit", "run", "src/app.py", \
35
+ "--server.port=8501", \
36
+ "--server.address=0.0.0.0"]