Spaces:
Sleeping
Sleeping
Nihar Shah commited on
Commit ·
6fab709
1
Parent(s): 186eebf
Enhance: Dockerfile - Add aggressive retry logic (10/15 retries) with increasing timeouts and fallback attempts
Browse files- Dockerfile +9 -3
Dockerfile
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Install system dependencies with retries for network resilience
|
|
|
|
| 6 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
gcc \
|
| 8 |
curl \
|
|
|
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
# Copy requirements first for better caching
|
| 12 |
COPY requirements.txt .
|
| 13 |
|
| 14 |
-
# Install Python dependencies with
|
| 15 |
-
RUN pip install --no-cache-dir --retries
|
| 16 |
-
(echo "
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Copy app code
|
| 19 |
COPY app/ ./app/
|
|
|
|
| 1 |
+
# Use python:3.11 as fallback if slim is unavailable
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
# Install system dependencies with retries for network resilience
|
| 7 |
+
# Using apt-get with retry logic for better reliability
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
gcc \
|
| 10 |
curl \
|
| 11 |
+
ca-certificates \
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
# Copy requirements first for better caching
|
| 15 |
COPY requirements.txt .
|
| 16 |
|
| 17 |
+
# Install Python dependencies with aggressive retry logic
|
| 18 |
+
RUN pip install --no-cache-dir --retries 10 --default-timeout 100 -r requirements.txt || \
|
| 19 |
+
(echo "First pip install attempt failed, waiting and retrying..." && sleep 10 && \
|
| 20 |
+
pip install --no-cache-dir --retries 10 --default-timeout 100 -r requirements.txt) || \
|
| 21 |
+
(echo "Second pip install attempt failed, final retry with longer timeout..." && sleep 15 && \
|
| 22 |
+
pip install --no-cache-dir --retries 15 --default-timeout 120 -r requirements.txt)
|
| 23 |
|
| 24 |
# Copy app code
|
| 25 |
COPY app/ ./app/
|