Spaces:
Configuration error
Configuration error
DNS fix 2
Browse files- Dockerfile +6 -3
- entrypoint.sh +4 -0
- runtime.yaml +1 -0
- test_dns.py +20 -0
Dockerfile
CHANGED
|
@@ -10,7 +10,10 @@ WORKDIR /
|
|
| 10 |
# Install requirements.txt
|
| 11 |
RUN pip install --no-cache-dir -r /requirements.txt
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
CMD ["
|
|
|
|
| 10 |
# Install requirements.txt
|
| 11 |
RUN pip install --no-cache-dir -r /requirements.txt
|
| 12 |
|
| 13 |
+
# copy test + entrypoint
|
| 14 |
+
COPY test_dns.py /test_dns.py
|
| 15 |
+
COPY entrypoint.sh /entrypoint.sh
|
| 16 |
+
RUN chmod +x /entrypoint.sh
|
| 17 |
|
| 18 |
+
EXPOSE 7860
|
| 19 |
+
CMD ["/entrypoint.sh"]
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
python /test_dns.py || true # run DNS test (won't crash the container)
|
| 4 |
+
exec uvicorn router:app --host 0.0.0.0 --port 7860
|
runtime.yaml
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
sdk: docker
|
|
|
|
| 2 |
docker:
|
| 3 |
build_args:
|
| 4 |
DNS_SERVERS: "8.8.8.8,1.1.1.1"
|
|
|
|
| 1 |
sdk: docker
|
| 2 |
+
app_port: 7860
|
| 3 |
docker:
|
| 4 |
build_args:
|
| 5 |
DNS_SERVERS: "8.8.8.8,1.1.1.1"
|
test_dns.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# test_dns.py
|
| 2 |
+
import socket, sys, requests, traceback
|
| 3 |
+
|
| 4 |
+
def test(host):
|
| 5 |
+
print("=== TEST", host, "===")
|
| 6 |
+
try:
|
| 7 |
+
print("getaddrinfo:", socket.getaddrinfo(host, 443))
|
| 8 |
+
except Exception as e:
|
| 9 |
+
print("RESOLVE ERROR:", repr(e))
|
| 10 |
+
try:
|
| 11 |
+
r = requests.get(f"https://{host}", timeout=7)
|
| 12 |
+
print("HTTP status:", r.status_code)
|
| 13 |
+
except Exception as e:
|
| 14 |
+
print("HTTP ERROR:", repr(e))
|
| 15 |
+
print()
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
for h in ("graph.facebook.com","www.googleapis.com"):
|
| 19 |
+
test(h)
|
| 20 |
+
sys.exit(0)
|