Aka18 commited on
Commit
062ff8a
·
verified ·
1 Parent(s): 73ebf19

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -12
Dockerfile CHANGED
@@ -6,7 +6,7 @@ RUN useradd --create-home --shell /bin/bash app_user
6
  # Set working directory
7
  WORKDIR /app
8
 
9
- # Environment variables - KEY FIXES for containerized environment
10
  ENV PYTHONUNBUFFERED=1
11
  ENV PYTHONDONTWRITEBYTECODE=1
12
  ENV PYTHONPATH=/app
@@ -16,39 +16,58 @@ ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
16
  ENV MPLCONFIGDIR=/tmp/matplotlib
17
  ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
18
 
19
- # CRITICAL FIXES for Hugging Face Spaces:
20
  ENV MPLBACKEND=Agg
21
- ENV GROQ_TIMEOUT=120
22
- ENV LANGCHAIN_TIMEOUT=120
 
23
  ENV HTTPX_TIMEOUT=120
 
 
24
 
25
- # Install system dependencies
 
 
 
 
 
26
  RUN apt-get update && apt-get install -y \
27
  gcc \
28
  g++ \
29
  curl \
 
 
 
 
30
  && rm -rf /var/lib/apt/lists/* \
31
  && apt-get clean
32
 
33
- # Copy requirements and install
 
 
 
34
  COPY requirements.txt .
35
  RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
36
- pip install --no-cache-dir --timeout=600 -r requirements.txt
37
 
38
- # Copy ALL your existing files (unchanged)
39
  COPY . .
40
 
41
  # Create necessary directories and set permissions
42
- RUN mkdir -p /tmp/.streamlit /tmp/matplotlib /app/temp && \
43
- chown -R app_user:app_user /app /tmp/.streamlit /tmp/matplotlib
 
44
 
45
  # Switch to non-root user
46
  USER app_user
47
 
 
 
 
48
  # Expose port
49
  EXPOSE 7860
50
 
51
- # Run your UNCHANGED app with container-optimized flags
52
  CMD ["streamlit", "run", "app.py", \
53
  "--server.port=7860", \
54
  "--server.address=0.0.0.0", \
@@ -56,4 +75,5 @@ CMD ["streamlit", "run", "app.py", \
56
  "--server.enableCORS=false", \
57
  "--server.enableXsrfProtection=false", \
58
  "--server.fileWatcherType=none", \
59
- "--browser.gatherUsageStats=false"]
 
 
6
  # Set working directory
7
  WORKDIR /app
8
 
9
+ # Environment variables optimized for Hugging Face Spaces networking
10
  ENV PYTHONUNBUFFERED=1
11
  ENV PYTHONDONTWRITEBYTECODE=1
12
  ENV PYTHONPATH=/app
 
16
  ENV MPLCONFIGDIR=/tmp/matplotlib
17
  ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
18
 
19
+ # CRITICAL: Network and API configurations for Hugging Face Spaces
20
  ENV MPLBACKEND=Agg
21
+ ENV GROQ_API_TIMEOUT=120
22
+ ENV GROQ_MAX_RETRIES=5
23
+ ENV GROQ_BASE_URL=https://api.groq.com/openai/v1
24
  ENV HTTPX_TIMEOUT=120
25
+ ENV REQUESTS_TIMEOUT=120
26
+ ENV CURL_TIMEOUT=120
27
 
28
+ # Network optimization for container environments
29
+ ENV HTTP_PROXY=""
30
+ ENV HTTPS_PROXY=""
31
+ ENV NO_PROXY="localhost,127.0.0.1"
32
+
33
+ # Install system dependencies including networking tools
34
  RUN apt-get update && apt-get install -y \
35
  gcc \
36
  g++ \
37
  curl \
38
+ wget \
39
+ ca-certificates \
40
+ dnsutils \
41
+ iputils-ping \
42
  && rm -rf /var/lib/apt/lists/* \
43
  && apt-get clean
44
 
45
+ # Update CA certificates for HTTPS connections
46
+ RUN update-ca-certificates
47
+
48
+ # Copy requirements and install with networking optimizations
49
  COPY requirements.txt .
50
  RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
51
+ pip install --no-cache-dir --timeout=600 --retries=3 -r requirements.txt
52
 
53
+ # Copy application files
54
  COPY . .
55
 
56
  # Create necessary directories and set permissions
57
+ RUN mkdir -p /tmp/.streamlit /tmp/matplotlib /app/temp /tmp/analysis_output && \
58
+ chown -R app_user:app_user /app /tmp/.streamlit /tmp/matplotlib /tmp/analysis_output && \
59
+ chmod -R 755 /tmp/.streamlit /tmp/matplotlib /app/temp /tmp/analysis_output
60
 
61
  # Switch to non-root user
62
  USER app_user
63
 
64
+ # Test network connectivity at build time
65
+ RUN curl -I https://api.groq.com --connect-timeout 10 --max-time 30 || echo "Groq API not reachable at build time"
66
+
67
  # Expose port
68
  EXPOSE 7860
69
 
70
+ # Run with network-optimized Streamlit settings
71
  CMD ["streamlit", "run", "app.py", \
72
  "--server.port=7860", \
73
  "--server.address=0.0.0.0", \
 
75
  "--server.enableCORS=false", \
76
  "--server.enableXsrfProtection=false", \
77
  "--server.fileWatcherType=none", \
78
+ "--browser.gatherUsageStats=false", \
79
+ "--server.maxUploadSize=200"]