amritn8 commited on
Commit
8343353
·
verified ·
1 Parent(s): df03070

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -7
Dockerfile CHANGED
@@ -3,33 +3,37 @@ FROM python:3.9-slim
3
  WORKDIR /app
4
 
5
  # Install system tools
6
- RUN apt-get update && apt-get install -y --no-install-recommends gcc python3-dev && \
 
7
  rm -rf /var/lib/apt/lists/*
8
 
9
  # Create folders for models and configs
10
  RUN mkdir -p /app/models /app/huggingface /tmp/.streamlit && \
11
  chmod 777 /app/models /app/huggingface /tmp/.streamlit
12
 
13
- # Set cache locations
14
  ENV TRANSFORMERS_CACHE=/app/models
15
  ENV HF_HOME=/app/huggingface
16
  ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
17
 
18
- # Streamlit settings (disables analytics and security for Spaces)
19
  RUN echo "[server]\n\
20
  enableCORS = false\n\
21
  enableXsrfProtection = false\n\
 
22
  [browser]\n\
23
  gatherUsageStats = false\n" > /tmp/.streamlit/config.toml
24
 
25
- # Install Python packages
26
  COPY requirements.txt .
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
- # Copy app code
30
  COPY app.py .
31
 
32
- # Health check and startup
33
  EXPOSE 8501
34
  HEALTHCHECK --interval=30s --timeout=5s CMD curl -f http://localhost:8501/_stcore/health
35
- CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
3
  WORKDIR /app
4
 
5
  # Install system tools
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ gcc python3-dev curl && \
8
  rm -rf /var/lib/apt/lists/*
9
 
10
  # Create folders for models and configs
11
  RUN mkdir -p /app/models /app/huggingface /tmp/.streamlit && \
12
  chmod 777 /app/models /app/huggingface /tmp/.streamlit
13
 
14
+ # Set environment variables
15
  ENV TRANSFORMERS_CACHE=/app/models
16
  ENV HF_HOME=/app/huggingface
17
  ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
18
 
19
+ # Streamlit config (fix for Hugging Face 403 upload error)
20
  RUN echo "[server]\n\
21
  enableCORS = false\n\
22
  enableXsrfProtection = false\n\
23
+ fileWatcherType = 'none'\n\
24
  [browser]\n\
25
  gatherUsageStats = false\n" > /tmp/.streamlit/config.toml
26
 
27
+ # Install Python dependencies
28
  COPY requirements.txt .
29
  RUN pip install --no-cache-dir -r requirements.txt
30
 
31
+ # Copy application code
32
  COPY app.py .
33
 
34
+ # Health check and expose port
35
  EXPOSE 8501
36
  HEALTHCHECK --interval=30s --timeout=5s CMD curl -f http://localhost:8501/_stcore/health
37
+
38
+ # Run the app
39
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]